Issue
I have added one new file uploader.rb in my last commit. I mean this file was not present in any earlier commits. But I don’t want to commit this file. In this commit with this file two old files has been committed. I have tried with git reset uploader.rb
. But this is not working. Is there any way so that I can reset this file only? Thanks in advance.
Solution
First, you need to reset your current branch to “undo” the last commit, which will leave uploader.rb
and the other two files in the state they were just prior to the newest commit:
git reset HEAD^
Then recommit the two files you wanted to leave in the original commit:
git add otherfile1 otherfile2
git commit
Answered By – chepner
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0