![]() there isn't any iphone.css (it is deleted -git warns about that-).$ git ls-files -error-unmatch newfile &>/dev/null & echo file is tracked Your repository has (among others) $ cd repoĪnd it is under Git control: $ git ls-files -error-unmatch iphone.css &>/dev/null & echo file is tracked Keep in mind Git doesn't track any metadata about your files Let's think about your files from a Git perspective. If it's showing that the file is renamed, you're good to go. Moral of the story: If you're not sure whether your file got renamed, issue a "git commit -dry-run -a". It might be the case that underline GIT implementation treats the two commands separately. Now you can see that the file is in fact renamed, and what's shown in git status is wrong, at least in this case. Now git status and git commit -dry-run -a shows two different results where git status shows bbb.txt as a new file/ aaa.txt is deleted, and the -dry-run commands shows the actual rename. The best thing is to try it for yourself. Heuristics we then use to show the renames.Ī dry-run uses the real renaming mechanisms, while a "rename detection" internally, and any commits you haveĭone with renames are totally independent of the Git really doesn't even care about the whole I can't tell you exactly why we see these differencesīetween git status and git commit -dry-run -a, but You can get a different output by running git commit -dry-run -a, which results in what you Warning: LF will be replaced by CRLF in index.html Will still show two different files: $ git status So, at first, you have to update the index on your own The index is updated after successful completion, So why didn't Git recognise the rename the first time around when I used Finder? # renamed: css/iphone.css -> css/mobile.css Let's use git mv instead: > $ git mv css/iphone.css css/mobile.css I am back to where I began: > $ git status Let’s undo the rename and let Git do the work. So Git now thinks I've deleted one CSS file, and added a new one. " to discard changes in working directory) I renamed my stylesheet in Finder from iphone.css to mobile.css: > $ git status However, doing just this tonight I ended up reverting to git mv. Git will recognise the file from the contents, rather than seeing it as a new untracked file, and keep the change history. I'd read that when renaming files in Git, you should commit any changes, perform your rename and then stage your renamed file.
0 Comments
Leave a Reply. |