How to commit changes to another pre-existent branch

git checkout -b your-new-branch
git add <files>
git commit -m <message>

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.

Leave a Comment