Occasionally I find my self in the following situation: I am working on branch (say master) and I am editing some files, but when it comes the time for a commit I realize that I would prefer to commit to a new branch (say experimental). In other words, the old branch (master) must remain intact and a new branch should be created that will look like:
.. -- master -- new commit
What is the easiest way to do that?
Currently, I commit to old branch, then create the new branch and finally reset the old branch. But that's really ugly.
git checkout -b branch # create new branch out of current head
git add <files> # the changes you had done in your working directory will be carried over
git commit -m "message" # commit!
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