I've cloned a master branch of a repository and made some changes. How do I create a branch with those changes? I don't want to push any of them to master.
If you haven't committed yet:
$ git checkout -b <new_branch_name> # create (and checkout) the new branch
$ git commit -a # commit to the new branch
If you have already committed (master
contains your changes):
$ git branch <new_branch_name> # create the new branch
$ git reset --hard HEAD^ # rewind master
$ git checkout <new_branch_name> # switch to the new branch
For future reference. Normally you branch off, before doing any changes. But for future reference
git stash save
git stash branch <branchname>
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