I\'m trying to take a branch with changes and bring it back to be identical to the upstream it diverged from. The changes are both local and have been pushed to github, so n
You can make a branch look like any other commit with git reset, but you have to do it in a round-about way.
To make a branch on commit look like a commit , you can do
git reset --hard
in order to make the contents of the working tree.
Then do
git reset --mixed
to change the branch back to the original commit but leaving working tree in the state.
Then you can add and commit the changes, in order to make your branch exactly match the contents of the commit.
It's counter-intuitive that to move from the state to the you need to do a git reset from to . However with the option --mixed the working tree is left at and the branch pointer set to , so that when the changes are committed the branch looks how we want.
Don't lose track of your commits, e.g. forget what is when doing git reset --hard .