Git create and push to new branch

Here are the steps to create a new branch and push it to a remote repository using Git:

Step 1: Create a new branch

Open your terminal and navigate to your local Git repository. Run the following command to create a new branch:

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 start working on the new branch, you need to switch to it. Run the following command:

git checkout <branch-name>

Replace <branch-name> with the name of the branch you created in Step 1. 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, run the following command:

git push -u origin <branch-name>

Replace <branch-name> with the name of the branch you created in Step 1. 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 push and pull changes to and from the remote repository.

That's it! Your new branch should now be created and pushed to the remote repository. You can verify this by running git branch -a to list all branches, including the new one:

* feature/new-login-system
  master

You can now start working on your new branch, making changes, committing, and pushing them to the remote repository as needed.