Commit changes to new branch with git

Commit changes to new branch with git

To commit changes to new branch with  git you can use the following three steps:

Create a new branch

 git checkout -b mynewbranchname

This will leave your current branch unedited, create a new branch called mynewbranchname, and you still have your uncommitted changes. It’s the parameter -b that tells git to create a new branch with a selected name.

Add files

 git add -- .

This adds your new files for git to track in the new branch.

Commit changes

git commit -a -m 'Adding my files'

This commits the files, and you’re done! The parameter -a tells git to automatically stage files that have been modified and/or deleted. and -m tells git that you provide a commit message.

Read more about commit in the git docs.