How to commit existing changes to a new git branch
2 min readJun 15, 2021
I assume if you're here you are trying to learn or to remember how to do something, so, the golden rule before you proceed is: do a backup.
If you're not familiar with some Git concepts it's really very easy to mess up with thing and lose work. We don't want that!
In your terminal, because I know you have one, type the line below:
cp -r <current_dir> <backup_dir>
Now let's create a new branch:
git checkout -b <name_of_your_branch>
Awesome! Now the usual process you used to do. Let's add the files to stage:
git add .
And finally, let's commit the changes:
git commit -m "your commit message"
And that's that simple. Git is a fantastic tool and I hope you enjoyed this short tutorial.
Happy coding!
Maybe your interested in: