How can I move my work and changes from the master branch to a newly created branch and leave the master branch intact after the move?
How can I move my work and changes from the master branch to a
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can create a new branch pointing to the current commit using
git branch branchname(orgit checkout -b branchnameif you want to check it out directly). This will basically duplicate your master branch, so you can continue working on there.If you have successfully copied the branch, you can reset
masterto its original point by usinggit reset --hard commitwherecommitis the hash of the commit that should be the last one on master.So for example you have a situation like this:
So you have checked out
masteron commit6, and you want to create a new branchticketpointing to that6while resettingmasterto3:And then you’re on
ticketpointing to commit6, whilemasterpoints to3.