Is it possible to move/rename files in Git and maintain their history?

前端 未结 14 2173
梦如初夏
梦如初夏 2020-11-22 04:42

I would like to rename/move a project subtree in Git moving it from

/project/xyz

to

/components/xyz

If I

14条回答
  •  抹茶落季
    2020-11-22 05:40

    Git detects renames rather than persisting the operation with the commit, so whether you use git mv or mv doesn't matter.

    The log command takes a --follow argument that continues history before a rename operation, i.e., it searches for similar content using the heuristics:

    http://git-scm.com/docs/git-log

    To lookup the full history, use the following command:

    git log --follow ./path/to/file
    

提交回复
热议问题