Moving Uncommitted changes to new branch

If you’ve made changes that you would not like to the current checkout branch, but rather create a new branch for it, you can do so by creating a new branch first, and then committing the changes:


1. Create a new branch (before committing your changes)

git checkout -b <new-branch-name>

2. Add,commit and push your changes

git add src/main/java/somefile.java
git commit -m "my new changes"
git push origin <new-branch-name>

Author: Dev

Full Stack Developer at one of the largest Banks in Canada.