Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:33:18+00:00 2026-06-17T10:33:18+00:00

I have two remote git repositories. origin and github I push my branch devel

  • 0

I have two remote git repositories. origin and github

I push my branch devel to both repositories.

git push -u origin devel
git push -u github devel

But then, when I do. git push It would only get pushed to github.

Is there anyway I can set up my two remotes, so that I can push changes to both repositories with one command ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:33:19+00:00Added an answer on June 17, 2026 at 10:33 am

    In recent versions of Git you can add multiple pushurls for a given remote. Use the following to add two pushurls to your origin:

    git remote set-url --add --push origin git://original/repo.git
    git remote set-url --add --push origin git://another/repo.git
    

    So when you push to origin, it will push to both repositories.

    UPDATE 1: Git 1.8.0.1 and 1.8.1 (and possibly other versions) seem to have a bug that causes --add to replace the original URL the first time you use it, so you need to re-add the original URL using the same command. Doing git remote -v should reveal the current URLs for each remote.

    UPDATE 2: Junio C. Hamano, the Git maintainer, explained it’s how it was designed. Doing git remote set-url --add --push <remote_name> <url> adds a pushurl for a given remote, which overrides the default URL for pushes. However, you may add multiple pushurls for a given remote, which then allows you to push to multiple remotes using a single git push. You can verify this behavior below:

    $ git clone git://original/repo.git
    $ git remote -v
    origin  git://original/repo.git (fetch)
    origin  git://original/repo.git (push)
    $ git config -l | grep '^remote\.'
    remote.origin.url=git://original/repo.git
    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
    

    Now, if you want to push to two or more repositories using a single command, you may create a new remote named all (as suggested by @Adam Nelson in comments), or keep using the origin, though the latter name is less descriptive for this purpose. If you still want to use origin, skip the following step, and use origin instead of all in all other steps.

    So let’s add a new remote called all that we’ll reference later when pushing to multiple repositories:

    $ git remote add all git://original/repo.git
    $ git remote -v
    all git://original/repo.git (fetch)               <-- ADDED
    all git://original/repo.git (push)                <-- ADDED
    origin  git://original/repo.git (fetch)
    origin  git://original/repo.git (push)
    $ git config -l | grep '^remote\.all'
    remote.all.url=git://original/repo.git            <-- ADDED
    remote.all.fetch=+refs/heads/*:refs/remotes/all/* <-- ADDED
    

    Then let’s add a pushurl to the all remote, pointing to another repository:

    $ git remote set-url --add --push all git://another/repo.git
    $ git remote -v
    all git://original/repo.git (fetch)
    all git://another/repo.git (push)                 <-- CHANGED
    origin  git://original/repo.git (fetch)
    origin  git://original/repo.git (push)
    $ git config -l | grep '^remote\.all'
    remote.all.url=git://original/repo.git
    remote.all.fetch=+refs/heads/*:refs/remotes/all/*
    remote.all.pushurl=git://another/repo.git         <-- ADDED
    

    Here git remote -v shows the new pushurl for push, so if you do git push all master, it will push the master branch to git://another/repo.git only. This shows how pushurl overrides the default url (remote.all.url).

    Now let’s add another pushurl pointing to the original repository:

    $ git remote set-url --add --push all git://original/repo.git
    $ git remote -v
    all git://original/repo.git (fetch)
    all git://another/repo.git (push)
    all git://original/repo.git (push)                <-- ADDED
    origin  git://original/repo.git (fetch)
    origin  git://original/repo.git (push)
    $ git config -l | grep '^remote\.all'
    remote.all.url=git://original/repo.git
    remote.all.fetch=+refs/heads/*:refs/remotes/all/*
    remote.all.pushurl=git://another/repo.git
    remote.all.pushurl=git://original/repo.git        <-- ADDED
    

    You see both pushurls we added are kept. Now a single git push all master will push the master branch to both git://another/repo.git and git://original/repo.git.

    IMPORTANT NOTE: If your remotes have distinct rules (hooks) to accept/reject a push, one remote may accept it while the other doesn’t. Therefore, if you want them to have the exact same history, you’ll need to fix your commits locally to make them acceptable by both remotes and push again, or you might end up in a situation where you can only fix it by rewriting history (using push -f), and that could cause problems for people that have already pulled your previous changes from the repo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two git repositories: report.git (Master on remote location) cloned.git (Local) I lost
I have two jobs on my Jenkins server. Both are based on git but
OK so I'm tracking a remote repo on two machines so both have the
I have two unrelated (not sharing any ancestor check in) Git repositories, one is
I have two git repositories on different PCs. I have some local branches on
I have two repositories origin and fork. I cloned origin locally and added fork
I have two remote branches in git, master and test . master reflects whatever
I have two different versions of git. In the 1.6.2 version, git push does
We have a two developer team and want use git. But I don't know
Possible Duplicate: How git works when two peers push changes to same remote simultaneously

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.