How to create a new branch in github
To create a new branch in GitHub, you can follow these steps:
Using the GitHub Web Interface:
- Log in to your GitHub account and navigate to your repository.
- Click on the "Code" button to view the repository's code.
- Click on the "Branches" tab.
- Click the "New branch" button.
- Enter a name for your new branch in the "Branch name" field. You can also choose a base branch from the dropdown menu.
- Click the "Create branch" button.
Using the Command Line:
- Open your terminal or command prompt.
- Navigate to your local repository using the
cd
command. - Use the
git branch
command to create a new branch. For example:git branch new-branch-name
Replace
new-branch-name
with the name you want to give your new branch.
Using Git Bash (on Windows):
- Open Git Bash.
- Navigate to your local repository using the
cd
command. - Use the
git branch
command to create a new branch. For example:git branch new-branch-name
Replace
new-branch-name
with the name you want to give your new branch.
Pushing the new branch to GitHub:
- Once you've created the new branch locally, you'll need to push it to GitHub.
- Use the
git push
command to push the new branch to GitHub. For example:git push -u origin new-branch-name
Replace
new-branch-name
with the name of your new branch.
Note: The -u
flag sets the upstream tracking information for the branch, which allows you to use git pull
and git push
without specifying the branch name.
That's it! Your new branch should now be created and pushed to GitHub.