Git Branch All Commands In-depth

0
92
Git Branch All Commands In-depth

Git Branch is today’s tutorial. Branches can be created, renamed, listed and deleted using git branch command. Keep in mind that all git branches are simply indicators to commits in a specific repository. So let’s get started.

# Requirements

  • Git installed in your system. Download

# Get Branch

You can get all local branches with following command.

git branch

Also, you can get all remote branches along with all local branches using -a option.

git branch -a

You can get a list of branches that are not merged with a current branch with --no-merged flag.

git branch --no-merged

Similarly, you can get a list of branches that are merged with a current branch with --merged flag.

git branch --merged

# Create Branch

You can easily create a branch using the following command.

git branch <branch-name>

Remember, pushing into remote with git push origin will automatically create a remote branch.

# Delete Branch

Execute the following command to remove a local branch.

git branch -d <branch-name>

Likewise, to force delete a branch use -D option.

git branch -D <branch-name>

Remote branch can be removed with using following command.

git push origin --delete <branch-name>

# Rename Branch

You can rename a local branch with the usage of following command.

git branch -m <branch-name>

Above command will rename the current branch. But if you want to rename another branch then use.

git branch -m <old-branch-name> <new-branch-name>

Learn more about Git.

Previous articleHow To Clone A Git Repository?
Next articleGit Checkout Documentation, Usage, Examples
Welcome to the world of web development, where technology and creativity come together to bring ideas to life. My name is Keyur Gadher, and as a web development blogger, I am here to share my knowledge and experience with you. From front-end web development to back-end programming, I will provide you with valuable tips, tricks, and techniques to help you create beautiful and functional websites that are tailored to your specific needs. Whether you're a beginner or a seasoned pro, I am here to help you take your web development skills to the next level. Join me today and let's start coding!

LEAVE A REPLY

Please enter your comment!
Please enter your name here