I had two files a.rb and b.rb. I manually renamed them in Sublime Text to c.rb and d.rb and made some changes to those files and pushed my branch to the remote repository using these commands:
git add
git commit -m "message"
git push origin branch-name
I should have done a git mv instead instead of manually renaming it.
Now I need a proper way to fix this issue so that others don't have merge conflicts. The only way I can think of is:
git checkout branch.
git rm c.rb.
git mv a.rb c.rb.
copy paste my old c.rb code to a.rb.
Is there a better way to fix this?
git mv doesn't do anything special. It just does the git add and the git rm for you. The fact that it is a moved file rather than an add and delete isn't recorded anywhere, it's inferred when you request a log.
All you need to do is make sure that you did a "git add" for the new name which I think you did, and a "git rm" on the existing file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With