How to work with (sub)directory renames in Git?

后端 未结 2 1019
难免孤独
难免孤独 2020-12-21 05:16

I\'m looking at using Git for local developer VCS support (this is for multi-diciplinary development).

Previous practice was that the top level directory would be r

相关标签:
2条回答
  • 2020-12-21 05:53

    On the command-line, you'd rename a file or directory with git mv. Your GUI should have an option for this.

    0 讨论(0)
  • 2020-12-21 06:00

    Git doesn't track renames, it retrospectively determines them as part of the log and show commands. You don't ever have to explicitly rename/move a file or directory using the git commands.

    Renames are determined by a difference threshold, if there's been an addition and a deletion of a file and the content is sufficiently similar, then git will consider it a rename/move.

    If you rename your directory outside of git, then do a git status, you'll see it's picked them up as a deletion. Now add them both to your index (git add -A will do it), you should now see it sees them as a rename.

    0 讨论(0)
提交回复
热议问题