我假設你有兩個名爲A和B的遙控器只配置了url。如果您不遵循參考文獻,請閱讀ProGit書中的relevant chapter。
1:從拉後有更新,將其推到B
$ # pull = fetch + (often fast-forward merge)
$ git fetch A # fetches all objects from A (all branches, commits; everything)
$ git push B 'refs/remotes/A/*:refs/heads/*'
$ # I've quoted so that the shell doesn't try to expand the *
編輯:我以爲你不希望合併修改到你的地方分支機構。
2:從一拉,與本地文件合併,然後將其推到B,與回購上B.合併
$ git pull A # fetch + attempt to merge changes in all branches
$ # Resolve any conflicts here
$ git push B '+refs/heads/*:refs/heads/*' # omit the + if it's a FF push
$ # Default is to push matching branches
編輯:以上不合並的變化B.如果你想這樣做,你必須從B中提取變更,並在推送前將它們合併到你的本地分支機構。
3:我想所有的A,我的本地回購和B具有相同的分支
$ git pull A
$ git checkout branchx
$ git reset --hard A/branchx # Warning! All local changes will be destroyed
$ # Repeat the above for all branches
$ git push B '+refs/heads/*:refs/heads/*' # Warning! Data in B is overwritten
編輯:如果你想刪除過時的跟蹤分支,運行
$ git remote prune A
$ git remote prune B
我推薦閱讀'git help workflows',它主要是關於分支管理,但是一旦你掌握了管理衆多知識庫的信息似乎不那麼繁重。 – xenoterracide 2010-07-12 04:42:21