Answer the question
In order to leave comments, you need to log in
How to remove a file from an existing commit in GIT?
For example, there is a branch with three commits, and in the second of them I need to remove the file from the index (roll it back to its original state, supposedly it has not changed). How can I do that? I suspect that you first need to execute the command git rebase -i HEAD~2
, and then I don’t know ...
Answer the question
In order to leave comments, you need to log in
I would do this:
git rebase -i HEAD~2
put edit on the commit being edited
git checkout HEAD~1
edit_file git commit -a --amend
git rebase --continue
I do this:
git reset --soft HEAD~1 (this command cancels the commit, leaving all its changed files in the index)
Then I just remove unnecessary files from the index and re-commit only what I need
with git rabase -i I make the last commit , which needs to be fixed
About the first command, it is better written here: https://stackoverflow.com/questions/7214039/how-do...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question