I did a bit of development against the wrong branch in my local repository. I did a git branch
without next doing a git checkout
. The commands look something like this:
#On branch development
git branch release-v0.2.0b
# changes and several commits
git push origin release-v0.2.0b
And that's when I realized I was working on the wrong branch. My github repo is in the proper state, but my local repo isn't. I've merged the changes from development into release-v0.2.0b, but I'd like to reset development back to the way it is in my github repo. What's the best way to go about this?
Even quicker you can just reset a local branch to a specific remote:
git reset --hard remote/branch
Where "remote" the name of your remote
Where "branch" the name of the remote branch
Just to make sure I understand the state of things: you created the release branch but did not check it out, so your commits are on the development branch in your local repository. You said you merged the changes into the release-v0.2.0b branch.
If that is the case, and there are no other commits on the development branch you need to preserve, just delete the local copy of the development branch and check it out again from origin.
First, verify what branches you have and which one you are on:
git branch -av
Then switch away from the development branch so you can delete it:
git checkout origin/development
git branch -D development
That actually leaves you on no branch, but you'll get back on a branch when you check it out again from the origin:
git checkout origin/development -b development
I suggest checking out origin/development to avoid unnecessary churning of files in your snapshot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With