Short version
What is the easiest way to make a branch equal to master again, discarding any differences?
Up until now, I simply used git branch -D wip, followed by git checkout -b wip, but that seems a bit silly.
Motivation
I often have a wip branch alongside my master branch, for ‘work in progress’. Sometimes the work on such a branch gets ‘left behind’ and when I rediscover it, I find I no longer want it. This rediscovery often happens when I want to use the branch to store a new set of ‘work in progress’ and I find I simply want to discard any differences with master, so the new ‘work in progress’ fits on top. Figuring out the differences is not worth the trouble: the solution described above works fine for me. Any better solutions to address this use case?
If you really want to blow away the previous branch with that name, and create a new one you could just use:
Using the capital version rather than
-bwill cause git to switch to the named branch, and reset it to the new starting point named as the last argument. If you’re currently at the desired starting point you could leave off the last argument (masterhere), it will default to usingHEAD.