git-mv

Odd `git mv` behaviour

喜你入骨 提交于 2019-12-24 08:32:54
问题 Last month I started to contribute to a GitHub repository by forking the corresponding repo, creating a feature branch and then submitting a pull request. While repeating that process for a couple of days, I ran into a weird problem when renaming files with the pre-installed Linux command mv and also with the Git command git mv . The actual problem is, that depending on when you move/rename a file with git mv , when you git add it and at what point you edit the renamed file, you either get:

unable to commit a file, accidentally renamed with mv

≯℡__Kan透↙ 提交于 2019-12-23 01:12:33
问题 I've accidentally used mv to rename a file which was under git. I renamed the file from lower case to uppercase keeping the name same. mv abc.java ABC.java I've also made changes and committed the file after that . How do I now make an actual git rename of this file? Git bash doesn't seem to understand the difference between ABC.java and abc.java. I'm not sure what changed on master(by others) but after moving to a branch, I'm no more able to commit my changes to the file. It says the old

Git: moving submodules recursively (nested submodules)

房东的猫 提交于 2019-12-03 19:24:32
问题 I have the following git structure - git-repo a -- subdirectory 2015 --- git-submodule b -- git-submodule c --- git-submodule d I would like to move the git submodule c to the folder 2015. I know of "dirty ways" to do this (that involve modifying .git/config and changing gitdir in several of the files in the .git/modules files) I recently read that git mv should be able to do this, i.e., running git mv c 2015/ This works fine for repositories in which there is no nested submodule (d in my

git copy file, as opposed to `git mv`

不想你离开。 提交于 2019-12-03 16:11:03
问题 I realize that git works by diff'ing the contents of files. I have some files that I want to copy. To absolutely prevent git from ever getting confused, is there some git command that can be used to copy the files to a different directory (not mv, but cp), and stage the files as well? 回答1: The short answer is just "no". But there is more to know; it just requires some background. (And as JDB suggests in a comment, I'll mention why git mv exists as a convenience.) Slightly longer: you're right

git copy file, as opposed to `git mv`

血红的双手。 提交于 2019-12-03 05:24:46
I realize that git works by diff'ing the contents of files. I have some files that I want to copy. To absolutely prevent git from ever getting confused, is there some git command that can be used to copy the files to a different directory (not mv, but cp), and stage the files as well? The short answer is just "no". But there is more to know; it just requires some background. (And as JDB suggests in a comment , I'll mention why git mv exists as a convenience.) Slightly longer: you're right that Git will diff files, but you may be wrong about when Git does these file-diffs. Git's internal

Practical use case of 'git rm' and 'git mv' with git?

戏子无情 提交于 2019-11-30 20:11:51
I know that git provides the 'git rm' and 'git mv' to remove/move files or directories. But, I can't see the practical use case for this. Normally, I just mv or rm the files or whatever in the command line, and after I'm done with all the necessary actions, I can just run 'git add -u' and 'git add .', as I asked and got answers in here . Am I missing something? Are there any cases that only 'git rm' and 'git mv' capable of? VonC git mv and git rm are about updating the index directly . While directly moving or deleting files in the working tree won't immediately affect the index. The GitFaq

Git: moving submodules recursively (nested submodules)

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 08:36:59
I have the following git structure - git-repo a -- subdirectory 2015 --- git-submodule b -- git-submodule c --- git-submodule d I would like to move the git submodule c to the folder 2015. I know of "dirty ways" to do this (that involve modifying .git/config and changing gitdir in several of the files in the .git/modules files) I recently read that git mv should be able to do this, i.e., running git mv c 2015/ This works fine for repositories in which there is no nested submodule (d in my case). However, when I run this command on my directory, I'm getting errors like fatal: Not a git

Practical use case of 'git rm' and 'git mv' with git?

风格不统一 提交于 2019-11-30 04:07:53
问题 I know that git provides the 'git rm' and 'git mv' to remove/move files or directories. But, I can't see the practical use case for this. Normally, I just mv or rm the files or whatever in the command line, and after I'm done with all the necessary actions, I can just run 'git add -u' and 'git add .', as I asked and got answers in here. Am I missing something? Are there any cases that only 'git rm' and 'git mv' capable of? 回答1: git mv and git rm are about updating the index directly . While

Trying to understand `git diff` and `git mv` rename detection mechanism

懵懂的女人 提交于 2019-11-27 05:38:01
This is a followup to another question I asked before . Before being edited, the initially created file something gets renamed to somethingelse which can be observed here : git mv something somethingelse The file somethingelse then gets renamed back to something before the second vim edit: git mv somethingelse something Basically in the following portion of the code : # If you add something to the first line, the rename will not be detected by Git # However, if you instead create 2 newlines and fill line 3 with new code, # the rename gets detected for whatever reason printf "\nCOMMAND: vim

Trying to understand `git diff` and `git mv` rename detection mechanism

主宰稳场 提交于 2019-11-26 11:40:55
问题 This is a followup to another question I asked before. Before being edited, the initially created file something gets renamed to somethingelse which can be observed here: git mv something somethingelse The file somethingelse then gets renamed back to something before the second vim edit: git mv somethingelse something Basically in the following portion of the code: # If you add something to the first line, the rename will not be detected by Git # However, if you instead create 2 newlines and