How to push to multiple git remotes at once. Useful if you keep mirrors of your...
source link: https://gist.github.com/rvl/c3f156e117e22a25f242
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.
Pushing to Multiple Git Repos
If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.
Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.
If in doubt about what git is doing when you run these commands, just
edit .git/config
(git-config(1)) and see what it's put there.
Remotes
Suppose your git remotes are set up like this:
git remote add github [email protected]:muccg/my-project.git git remote add bb [email protected]:ccgmurdoch/my-project.git
The origin
remote probably points to one of these URLs.
Remote Push URLs
To set up the push URLs do this:
git remote set-url --add --push origin [email protected]:muccg/my-project.git git remote set-url --add --push origin [email protected]:ccgmurdoch/my-project.git
It will change the remote.origin.pushurl
config entry. Now pushes
will send to both of these destinations, rather than the fetch URL.
Check it out by running:
git remote show origin
Per-branch
A branch can push and pull from separate remotes. This might be useful
in rare circumstances such as maintaining a fork with customizations
to the upstream repo. If your branch follows github
by default:
git branch --set-upstream-to=github next_release
(That command changed branch.next_release.remote
.)
Then git allows branches to have multiple branch.<name>.pushRemote
entries. You must edit the .git/config
file to set them.
Pull Multiple
You can't pull from multiple remotes at once, but you can fetch from all of them:
git fetch --all
Note that fetching won't update your current branch (that's why
git-pull
exists), so you have to merge -- fast-forward or
otherwise.
For example, this will octopus merge the branches if the remotes got out of sync:
git merge github/next_release bb/next_release
References
Recommend
-
59
git-remote-aws git-remote-aws is a git remote helper for pulling data from an AWS account just like pulling from a Git remote. Reposit...
-
35
Monday, February 10, 2020 Working with different remotes in git One of the things that is typical when working with gitlab/git...
-
5
Logitech is done making Harmony remotesIt's official -- the long-running universal remote line is ending.
-
8
Logitech has axed its Harmony remote lineup for good. There were a lot of speculations and rumors about Logitech killing its universal Harmony Remote, and the company has officially confirmed this. ...
-
4
Logitech says it's the end of the line for its Harmony remotes By David Nield 8 hours ago Support will continue though ...
-
4
Logitech to discontinue Harmony universal remotes Search Logitech’s Harmony remotes are oft considered the supreme universal remote, able to control all your infrared devices from...
-
5
srbNYC macrumors 6502 Original poster Jul 7, 2020
-
14
本指南介绍了如何删除Git remotes远程分支。Git remote是一个指针,它指向通常托管在远程服务器上的存储库的另一个副本。通常,在使用Git时,您将只有一个命名为origin的remote,而针对不同的功能和环境的分支则不同。 源是在克隆存储库并指向克...
-
3
CES 2022: Colour changing cars and remotes that eat wi-fiBy Jane WakefieldTechnology reporter Published4 days agoRelated Topics
-
3
This month felt a little slow in times and getting into the 'groove' of handling git remotes took me longer than I had hoped. Let's see if feelings and facts line up. rev-spec resolution with perfect disambiguation The parser emits...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK