Reputation: 3539
we are using git at work. we want to move a directory called "Workflows" from under Source/Workflows
to a new location Source/Sites/CompanySite/Workflows
my colleague did a copy of that directory to the new location "Source/Sites/CompanySite/Workflows" and checked-in before doing a "git mv" command or even doing a move.
So, we have new copies of the files in that location with no history.
But because we want to just move files keeping their history, so I deleted the new copy and tried to do "git mv" to move the source files, while keeping the history. And I know that git will recognize that we are renaming even without "git mv"
But because my colleague copy has already a history there (which is an empty one), so even when I delete it it keep that "new history".
Then no matter what I do, I am not able to move those files with their "original history".
because it always keeping the "new history" that was there.
I hope my question is clear
How can I move these files keeping their history. maybe "purging" that old copy????
Upvotes: 3
Views: 1563
Reputation: 25651
it depends on your requirements: there is a possibility to use git-filter-branch
this allows you to apply a shellscript on every commit like: git filter-branch --tree-filter 'rm filename' HEAD
be aware though that it will create new commit-ids for each commit. See also this SO Question on moving files with filter-tree.
Upvotes: 1
Reputation: 411192
git mv
doesn't actually ensure that Git will see it as a move; it may still treat it as a delete + addition, anyway. Git infers moves, but doesn't record them.
If you want the history, try passing the --follow
flag to git log
—it may be able to recognize the connection to the original and show the history for it.
Upvotes: 1