DEV Community

Álex Sáez
Álex Sáez

Posted on • Originally published at alexsaezm.com

2 1

Where are all the branches?!

Recently I started using gh for working with my forks. Before that I used to add the remotes manually.

When cloning a fork, gh adds the original repository as a upstream remote which is what I used to do manually, but if you try to find the branches, you'll find that it only tracks the default one.

For tracking all of the branches in the upstream remote too, you just need to find the fetch line under the upstream section in the .git/config file.

For example, this is the content of my .git/config after cloning my go fork:

$ cat .git/config 
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@github.com:alexsaezm/go.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "upstream"]
    url = git@github.com:golang/go.git
    fetch = +refs/heads/master:refs/remotes/upstream/master
Enter fullscreen mode Exit fullscreen mode

But what I really want under the upstream entry is this:

[remote "upstream"]
        url = git@github.com:golang/go.git
        fetch = +refs/heads/*:refs/remotes/upstream/*
Enter fullscreen mode Exit fullscreen mode

After changing that file, you can do a git fetch --all :)

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay