Git – Remove commit from history

If it’s only on your local PC (or noone checked out your changes): Use: git log to find the commit you want to remove. Copy hash (the long sqeuence like: e8348ebe553102018c…). Use: git rebase -i [hash]~ : for example git rebase -i e8348~ Just remove the commit you don’t need and save the file. Interactive … Read more

How can I remove a commit on GitHub?

Note: please see an alternative to git rebase -i in the comments below— git reset –soft HEAD^ First, remove the commit on your local repository. You can do this using git rebase -i. For example, if it’s your last commit, you can do git rebase -i HEAD~2 and delete the second line within the editor window that pops up. Then, force … Read more

git status (nothing to commit, working directory clean), however with changes commited

Your local branch doesn’t know about the remote branch. If you don’t tell git that your local branch (master) is supposed to compare itself to the remote counterpart (origin/master in this case); then git status won’t tell you the difference between your branch and the remote one. So you should use: or with the short option: This options –set-upstream-to (or -u in … Read more

tech