Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put current changes in a new Git branch [duplicate]

People also ask

Can I create a new branch with current changes?

You can do a checkout and create a new branch with all local and current changes transferred over.

How do I commit changes to a new branch?

First, checkout to your new branch. Then, add all the files you want to commit to staging. Lastly, commit all the files you just added. You might want to do a git push origin your-new-branch afterwards, so your changes show up on the remote.


You can simply check out a new branch, and then commit:

git checkout -b my_new_branch
git commit

Checking out the new branch will not discard your changes.