Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

hpr2130 :: Git push to two repositories at once

Klaatu demonstrates how to perform one git push to two separate repositories

<< First, < Previous, Latest >>

Hosted by Klaatu on Friday 2016-09-30 is flagged as Clean and is released under a CC-BY-SA license.
Tags: git,git push,multiple repositories.

Listen in ogg, spx, or mp3 format. | Comments (4)

Part of the series: Version Control

This is an open series in which Hacker Public Radio Listeners can share their knowledge and experience of version or revision control systems such as Bazaar, Mercurial, Subversion, CVS and Git.

  1. Set up your git remotes (‘origin’ and ‘foo’)

  2. Create a new remote (‘all’) entry to encompass the existing targets

  3. Adjust ssh config as needed

  4. git push all HEAD

Show Transcript

Automatically generated using whisper

whisper --model tiny --language en hpr2130.wav

<< First, < Previous, Latest >>


Subscribe to the comments RSS feed.

Comment #1 posted on 2016-10-02T14:12:28Z by clacke

I figured :-)

I thought, "Hey, this is probably useful if you want to host something at gitlab and have an unofficial clone at ". One minute later ... yep. :-)

Comment #2 posted on 2016-10-02T16:11:54Z by clacke

explicit push

Very cool discovery! I never even considered the idea that you could have several URLs for a remote.

As you mentioned that this kind of mixed remote would make it "impossible" (without adding remotes) to push to only one of the URLs, I though I should mention something that probably not everyone knows:

You don't need to set up a remote to fetch or push. You can use an explicit URL instead of a remote name:

git push ssh://my.server/~/git/myrepo HEAD:master

In fact, because I forget what the various options are for managing references/branches, I often use this to remove a reference in the local repository.

git push . :refs/heads/whatever_branch

Comment #3 posted on 2016-10-08T09:17:18Z by klaatu

explicit push

Funny you mention the explicit push. I knew about it, or at least I knew about the explicit pull, because I use it when migrating git repositories at work...but only with local URI's. It never dawned on me that it could be done with non-local URI's. Thanks for the tip!

Comment #4 posted on 2016-11-02T12:20:52Z by Dave Morriss

Thought I'd never use this

This was interesting, but I thought I'd never use it. However, I had an instance recently where making a GitHub copy of a repository on a GitLab instance was desirable. It was straightforward to set up and worked flawlessly.

Thanks for explaining the process.

<< First, < Previous, Latest >>

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?