How to List Remote Branches in Git, and Why You Need To
source link: https://www.makeuseof.com/git-remote-branches-list-how-to/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to List Remote Branches in Git, and Why You Need To
Remote branches connect your local repository to others. Understanding how to list them is useful in many situations.
Depending on your project structure, you might have one or more remote Git branches in a repository. Listing them helps you keep track of the state of your project.
Whether you want to compare, switch, or delete your remote Git branches, requesting a list enables you to view them beforehand.
How to List Your Remote Git Branches
When you create a new branch in Git, it's local until you push it to your remote repository. While listing your remote Git branches specifically, local ones won't appear.
Use the git branch -r command to see your remote branches via the command line:
git branch -r
While the above provides some information about your Git branches, you can get more detail about the last commit made to each branch with the -rv flag:
git branch -rv
You can also display your remote branches in columns. This can be useful if you have many repositories to view at once:
git branch -r --column
If you wish to get a list of all remote branches, including the SHA1 hash of the most recent commit for each, use this command:
git ls-remote --heads origin
How to View Your Remote Branches on GitHub Web
If you’re hosting your remote repository on GitHub, an easy way to view your remote branches is via the github.com web interface. This option is handy if you're not a fan of the command line.
Once in your target repository, click the master dropdown at thetop-left (you might see main if you've changed the default name). You'll see all published branches here.
Never Make a Mistake With Git Branches
Mistakes are more likely when you manage a project with many branches. But as you can see, listing your remote Git branches doesn't only help you get their names but gives you information about the latest commit on each.
If you can track your commits, and keep an eye on your Git branches, you’re less likely to delete or merge something you shouldn’t. Using the branch command to its full extent will give you the power you need to keep everything in check.
Recommend
-
70
Branches are one of the most misunderstood concepts in git and yet they are so simple to understand. How many uncomfortable situations have you been when dealing with branches? All the rebases and…
-
7
Shannon Crabill — Front End Software EngineerSkip to content You may run into a situation where a branch of a project doesn’t need to share history wi...
-
9
Reworking Git Branches with git filter-branch Posted at Mar 16, 2020 Within Debezium, the project I’m working on at Red Hat, we recently encoun...
-
7
Git Workflow with branchesotsukare Thoughts after a day of workGit Workflow with branches Mer 0...
-
11
Remove all git branches except masterPublished: 2020.12.20 | 1 minutes readAfter working on a project for a while, it’s easy to end up with a lot of legacy branches that are not needed anymore. Removing them one by one would b...
-
14
Dealing with changes to git default branches As you may have heard by now, the default git branch name is changing from master to main
-
6
This post is part of my Byte Series, where I document tips, tricks, and tools that I've found useful.If you are anything like me, you have a lot of branches in your local projec...
-
4
List Git Branches Parameter
-
5
There are 4 different Git commands you can enter into your command line to list all of the remote branches of a repo. I will show you command line code examples of each of these.For all of these examples, I will use
-
6
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK