-
Notifications
You must be signed in to change notification settings - Fork 140
Copying or Splitting a File in Git
Peter Doak edited this page Jul 16, 2018
·
2 revisions
When a file is copied in the same directory this git mv trick keeps git blame simple, i.e. no extra switches are required.
When using this trick only the "original" file gets the full log without a switch.
However if a file is moved to a different directory generally you will need to use some extra git magic to regain your log and file history.
Git is better than this and in general the above trick is to placate those of us that grew up with "file" based history like in SVN and CVS.
git log --follow <file>
git blame -C -M <file>
The normal interactive or automatic rebase will try to collapse the split that maintains the "copied" file history. To prevent this one must rebase preserving merges '-p'.
git rebase -p develop
git commit -a -m "something to effect of keep both sides of merge for file history"
git rebase --continue