i2tutorials

Git – Branch

Git Branch 

 

The git branch command is used to manage branches in a Git repository. Branches are an important feature of Git, as they allow multiple parallel lines of development to take place within a single repository.

Git Branch

There are several types of branches in Git, each serving a different purpose:

The git branch command is used to manage branches in a Git repository. It allows us to list, create, delete, and switch between branches.

Here are some of the most common uses of the git branch command:

List Branches: To see a list of all the branches in the current repository, use the following command:

$ git branch

This will display a list of all the branches in the repository, with the current branch indicated by an asterisk (*).

Create a Branch:

To create a new branch, use the following command:

$ git branch <branch-name> 

This will create a new branch with the specified name.

Push Branch to remote repo :

To push the created branch to the remote repository, use the following command :

$ git push origin <branch-name> 
$ git push origin india

Switch to a Branch:

To switch to an existing branch, use the following command:

$ git checkout <branch-name>

This will switch to the specified branch and update the working tree to reflect its contents.

Delete a Branch:

To delete a branch, use the following command:

$ git branch -d <branch-name>

This will delete the specified branch. Note that you cannot delete a branch if it has not been fully merged into another branch.

$ git branch -d <branch-name>
$ git push origin -d <branch-name>

These are the basic operations for managing branches in Git. By using branches, you can work on different features or bug fixes in parallel and easily switch between them as needed.

 

Exit mobile version