

Others have pointed out the methods to do this: Push the new commit and origin will be fixed. This creates a new commit that reverses the changes you made. So the best command to use is git revert. Because of this, you probably do not want to rewrite the history. To be clear: I am not trying to modify my remote repo, just get my local repo to look like the server. Since you've already pushed to origin, your change has been published for others to see and pull from.


There's a nice diagram on the bottom of this page which shows you how the process works - you make some changes, stage them (by running git add), and then finally commit them to the repository (through the creatively named git commit). Git doesn't compare the changes that haven't been committed to the remote branch when it decides what to pull thus, from Gits point of view, your local and remote repositories are at the same point in time, even though your local repository has unstaged changes (changes that you have not git added). You need to pass the -f because you're replacing upstream history in the remote. (Example push: git push -f origin bugfix/bug123) This will undo the last commit and push the updated history to the remote.
This is due to your git push, which synced the remote with your local repository. git reset -hard HEAD1 git push -fWhen you run git revert, a text editor opens up. In other words, the original commit remains in the version history and the new commit reverts it. This creates a new commit that undoes the unwanted commit. Git pull is telling you your repository is up to date because your local repository and your remote repository both point to the same HEAD (the last commit). The easiest way to undo a commit after the push is by reverting it. Git pull says my local repo is "up to date"
