[Git] How to remove diverged changes from a local branch
by Riley MacDonald, August 17, 2018
Sometimes when switching between development machines I end up with unwanted differed changes on my local branch that were never pushed to the remote. This results in a message such as:
$ git status On branch master Your branch and 'origin/master' have diverged, and have 1 and 11 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean |
In most cases I just want to pull the changes from the remote and destroy my local un-pushed changes. To do so reset the branch pointer to the remote by executing:
$ git checkout master $ git reset --hard origin/master |