Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a fix for manually renamed files in a git project?

Tags:

git

github

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?

like image 419
newbie Avatar asked Oct 25 '25 15:10

newbie


1 Answers

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.

like image 200
jcoder Avatar answered Oct 27 '25 05:10

jcoder