2

How to List Remote Branches in Git, and Why You Need To

 2 years ago
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.
neoserver,ios ssh client

How to List Remote Branches in Git, and Why You Need To

Published 11 hours ago

Remote branches connect your local repository to others. Understanding how to list them is useful in many situations.

GitHub repositories on a computer screen

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.

Remote branch list on GitHub

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
    • geeks.uniplaces.com 6 years ago
    • Cache

    Mastering git branches – uniplacesgeeks

    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
    • shannoncrabill.com 3 years ago
    • Cache

    Orphan Branches in Git

    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
    • www.otsukare.info 3 years ago
    • Cache

    Git Workflow with branches

    Git Workflow with branchesotsukare Thoughts after a day of workGit Workflow with branches Mer 0...

  • 11
    • pawelgrzybek.com 3 years ago
    • Cache

    Remove all git branches except master

    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
    • elijahmanor.com 2 years ago
    • Cache

    List Recent Git Branches

    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
    • plugins.jenkins.io 2 years ago
    • Cache

    List Git Branches Parameter | Jenkins plugin

    List Git Branches Parameter

  • 5
    • www.freecodecamp.org 1 year ago
    • Cache

    Git List Remote Branches

    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
    • www.wisdomgeek.com 8 months ago
    • Cache

    Delete git branches that do not exist on remote

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK