Create new branch and push
Here are the steps to create a new branch and push it to a remote repository:
Step 1: Create a new branch
You can create a new branch using the following command:
git branch <branch-name>
Replace <branch-name>
with the name you want to give your new branch. For example:
git branch feature/new-login-system
This will create a new branch called feature/new-login-system
that is based on the current branch (usually master
).
Step 2: Switch to the new branch
To switch to the new branch, use the following command:
git checkout <branch-name>
Replace <branch-name>
with the name of the new branch you just created. For example:
git checkout feature/new-login-system
This will switch your local repository to the new branch.
Step 3: Make changes and commit
Make some changes to your code, add them to the staging area, and commit them:
git add.
git commit -m "Initial commit for new login system"
Step 4: Push the branch to the remote repository
To push the new branch to the remote repository, use the following command:
git push -u origin <branch-name>
Replace <branch-name>
with the name of the new branch. For example:
git push -u origin feature/new-login-system
The -u
flag sets the upstream tracking information for the branch, which allows you to use git pull
and git push
without specifying the remote branch.
That's it! Your new branch should now be created and pushed to the remote repository.