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

前端 未结 14 2203
梦如初夏
梦如初夏 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:49

    I do:

    git mv {old} {new}
    git add -u {new}
    
    0 讨论(0)
  • 2020-11-22 05:49

    I make moving the files and then do

    git add -A
    

    which put in the sataging area all deleted/new files. Here git realizes that the file is moved.

    git commit -m "my message"
    git push
    

    I do not know why but this works for me.

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