Quantcast
Channel: Git push doesn't ignore files in .gitignore - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by matrik for Git push doesn't ignore files in .gitignore

$
0
0

The solutions here will work but you will lose other changes in the same commit. If you don't want to lose the other changes in the same commit, and you didn't push the commit yet, you have to change HEAD back to a previous commit, add the changed file and amend:

First find which commit you would like to return to:

$ git log --oneline

Then, it's needed to checkout another branch because you cannot change the HEAD in the active branch:

$ git checkout master

Then, change the head of the branch to an older commit:

$ git branch -f <branch_name> <commit_id>

Then, add the changed file to current commit:

$ git add <filename>

Then, amend the change into current commit:

$ git commit --amend --no-edit

That multi-step solution worked out for me to not lose changes and add new changes to a previous commit.


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>