Git new branch then roll back to previous version
I have a few different branches including my master branch. I want to create a new branch from master which I think can be done like this correct me if I’m wrong.
git branch masterDup git checkout masterDup
I then want to roll the masterDup branch back to an old version. Can this be done without effecting the master or any other branches. So only masterDup would be rolled back.
If so how would I roll back using the commit ID just for this newly created branch.
I have the commit ID in the my log history. commit 6f041c1e37bb97aab35678d35c8923fabe33c8d2c
I’m using terminal for my git commands.
2 Solutions collect form web for “Git new branch then roll back to previous version”
Sure, you check out a new branch with
git checkout -b masterDup
and then you reset it to an earlier version
git reset --hard HEAD~x
where x is x versions back (or use the hash if you like)
edited this answer, see comments.
Right after the checkout of the new branch
git reset --hard 6f041c1e37bb97aab35678d35c8923fabe33c8d2c