Question

I moved a lot of files in 2 commits, in each commit the movement is being detected. However if I squash those 2 commit toghether the movement operations done in the second commit is being detected as add and delete.

Any ideas of How I could resolve this problem?

whatsgoingon

Thanks.

Was it helpful?

Solution 2

The problem is that git always stores file moves as delete/add.

Only later does git (or git clients) try to be helpful and show them as moves.

See:

How can I prevent git from thinking I did a rename

Make git ignore rename

OTHER TIPS

Git does not track file moves. Git only tracks content. It just happens to be that some commands like git diff and git status will recognize when one file was removed, another one was added, and their content looks very similar that it might have been a file move instead.

So in your case, Git’s frontend is able to recognize the moves for the individual commits, but not for the combined one. That doesn’t change what is stored underneath (no moves at all), but is just a visual issue.

You could try playing with the value of the --find-renames argument to make Git recognize moves despite more content changes. The argument is available for example for git show.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top