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
1 Answer
Reset to default 0Does 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.