(Git) Create a Branch From Local Repository
In this article, I will show you how to create a new branch in your local repository and push it to your remote repository.
1. Create a branch in local repository
First, move to your project directory (your local branch) and create a new branch. After you create a new branch, switch to the branch.
// Move to your local repository
cd /Users/YourUserName/...YourLocalRepository/// Create a new branch
git branch develop/#1branch// Switch to your brand new branch
git checkout develop/#1branch
2. Add files to your local repository and commit
Next you need to add your files to your new branch. Simply add and commit like below.
// Add the files
// NOTE: '.' will add all files which have been changed
git add .// Commit the changes
git commit -m "Your commit message here."
3. Push your new branch to remote
Finally, push your files to the remote repository as a new branch.
// Push your files
git push -u origin develop/#1branch
Note: If you use -u option, you can simply type ‘git push’ from next time. It will automatically push your commit to that branch.
And that’s everything!