There are many ways we can create a branch locally and remote
- How to create a branch from command line There are multiple ways to create a branch.
Here are following steps to create a branch
- you need to be on the branch that is source branch to create a new branch
- First, let’s create a new branch in locl repository
- you can make a changes in local branch
- Commit and push the changes into remote repository.
- It create a branch in remote repository.
git checkout -b branch-name
It creates a local branch named branch-name
in local repository. The branc created from a current branch.
You can make your changes in local branch, need commit the changes in local branch
git push -u origin branch-name
This pushes the new branch into remote repository and creates a remote branch.
If other developers are working on remote repository, You need to run below commands to load this new branch in remote repository.
git fetch
This will fetch all remoate branches into local repository.
To checkout a branch, run below command
git checkout branch-name