0

What would be a good a way to fetch all branches (to check consistency via branch -av between both repos) in [remote "all"] after a push? I have a fetch for both origin and backup, but it's only fetching the first.

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = git@host:origin/repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[remote "backup"]
        url = git@host:backup/repo.git
        fetch = +refs/heads/*:refs/remotes/backup/*
[remote "all"]
        url = git@host:origin/repo.git
        url = git@host:backup/repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        fetch = +refs/heads/*:refs/remotes/backup/*
[branch "master"]
        remote = all
        merge = refs/heads/master

I'm currently going the route of typing git push all [branch], followed by git fetch all since the only fetch it's automatically grabbing is the first repo listed in [remote "all"] (even though I have both listed.)

2 Answers 2

2

You can't do that for fetch. (You can for push, but still I advise against it. If you want to keep your all, I'd at least recommend setting the url to something invalid and setting the push URLs via pushurl—although I admit I have never tested this setup.)

What you can and should do instead is declare multiple remotes (as you did, remote origin and remote backup) and then declare a remote group as described in the git remote documentation. The default group is named default, and if you do not define one, git remote update defaults to finding all remotes automatically, skipping only those configured with a special "I am not in the default set" flag.

Hence, simply delete the all repo and instead of running git fetch, run git remote update (or git fetch --all). (Or leave all in there for pushing, but my OCD still says "don't do that" :-) )

Sign up to request clarification or add additional context in comments.

Comments

0

The command git fetch --all simply fetches all and updates the current branches seen with git branch -av.

Adding [remote "all"] to .git/config then keeps multiple repos consistent, while allowing individual pushes if necessary.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.