I've read in various FAQs that git doesn't explicitly track renames/moves, preferring to look for identical (or in some situations similar?) files. That's great, but will it cope with this situation: a friend's remote repository has a new feature (i18n) involving some new files at debian/po/*.po
. I have my own fork of this project, and want to merge this feature but put the files at just po/*.po
(I can do that as two commits, or whatever is necessary). I expect the remote repo will continue to receive updates to the feature, and I want to just merge/cherry-pick those commits and have them applied to the files in my new location. Can git do that, perhaps with some sort of mapping of "these files have moved over here now"? Or is it more pain than it's worth and should I just accept the slightly odd debian
path in my repo?
views:
390answers:
2
+3
A:
use git mv
and everything will be AOK.
Why not just try it instead of asking? You can always reset easily in git. :)
Pod
2009-11-16 00:06:34
Well, I just wanted to see if anyone pointed out any gotchas that could crop up later if something strange that I didn't try happens in the remote repo and I didn't frobble the correct magic chicken when I did the move or that merge. I've only been using git a few weeks, and still have a (un)healthy dose of paranoia left over from lesser VCSs. :-)
Chris Boyle
2009-11-16 00:25:39
If the files wildy diverge then it will have trouble tracking the change, but it'll have that problem whether you rename it or not ;)
Pod
2009-11-16 00:27:07
Thanks, it does indeed all look OK so far.
Chris Boyle
2009-11-16 01:14:20
FYI: "git mv" is no different from renaming the file yourself and commiting the changes like that. It's just easier.
Pod
2009-11-16 11:30:18
+1
A:
Alternatively, rename the files using mv
, and invoke git add --all
to stage all the delete operations and add the untracked files (the new file names). Without --all
, you must explicitly stage the delete operations and new file names separately. Don't use git add --update
, either, as this will stage all the delete operations, but won't add the new file names.
Note that you'll likely want to perform these operations in a local branch so that you don't inadvertently push
them to your friend's master branch or your friend doesn't pull
them into his master branch.
Derek Mahar
2009-11-17 22:28:08