最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

git - How to make gitlab recognize that file move is file removed and file added? - Stack Overflow

programmeradmin2浏览0评论

I moved a file from one directory(code) to another(lib), committed and pushed the change to remote. But gitlab shows this file as modified in lib, rather than deleted from code and added to lib. How should I get git to recognize the delete and add? Especially recognize that this file was deleted from the code directory? My concern is whether the delete will be recognized when I merge this(pull/merge request) to mainline.

I moved a file from one directory(code) to another(lib), committed and pushed the change to remote. But gitlab shows this file as modified in lib, rather than deleted from code and added to lib. How should I get git to recognize the delete and add? Especially recognize that this file was deleted from the code directory? My concern is whether the delete will be recognized when I merge this(pull/merge request) to mainline.

Share Improve this question edited Jan 20 at 12:27 Swarnagowri asked Jan 20 at 12:21 SwarnagowriSwarnagowri 2952 silver badges10 bronze badges 1
  • You can't force it... that is actually a guess that git does. Git does not care for that. It only keeps the files present at a moment in time and their contents... the fact that it was moved or not is done after the fact when operations require it. – eftshift0 Commented Jan 20 at 12:37
Add a comment  | 

1 Answer 1

Reset to default 0

Does it matter? Gitlab sees that you barely changed the file, and just moved it around, so it is displayed as such.

A change in code will be executed exactly like you made it in a future merge. The file in the old location will be removed, and the new location will be populated. If you have touched the file manually on a checkout location and pull this change, you'll probably get a conflict for the changed file (in stead of a delete/overwrite of the file).

If there is additional context that you would like people to have when viewing your change, add that to the commit message for people to read.

发布评论

评论列表(0)

  1. 暂无评论