Reputation: 189656
Is there a git equivalent of hg rename -A
in Mercurial, which renames a file in the version control repository "after the fact", in case I or an application I run decides to rename a file?
Upvotes: 1
Views: 107
Reputation: 488163
Git doesn't actually record renames: instead, it synthesizes them later, when comparing two trees (as for git show
or git log -p
, or even git status
). So it's not necessary to use git mv
to create-and-record a rename operation.
As Keith Thompson noted in a comment, you can use the two-step method of putting the name back temporarily, then using git mv
to un-undo (or re-do) the rename along with the steps needed to get git to see it. But you can also git rm --cached
the old name and git add
the new name to update the index. As long as the file contents are unchanged (or sufficiently similar), git will subsequently show the file as moved.
Upvotes: 3