【发布时间】:2012-10-22 14:57:43
【问题描述】:
我正在尝试将远程存储库克隆到我的本地工作区,并将内容推送到我设置维护的新裸存储库,此存储库需要不时从上游存储库更新,并且需要将新内容推送到本地仓库也是如此。
这是一个例子:
git clone ssh://username@whatevergitrepo.com/project
我创建了一个裸仓库作为 project_local
mkdir project_local.git
git init --bare --share=2 project_local.git
一旦远程仓库被克隆到我的工作区,由于这个远程仓库有多个分支,
branch1
branch2
.
.
branchN
这是我从远程获取所有分支并推送到本地裸仓库的操作。
cd project
git branch -a >&/tmp/branchinfo
sed s,.*/,, /tmp/branchinfo >&/tmp/branchinfo1 #this remove everything before the last '/' before the actual name of the branch
for i in `cat /tmp/branchinfo1`; do git checkout $i; done #checkout all the branches from remote site.
for i in `cat /tmp/branchinfo1`; do git push project_local.git $i; done # Push all the remote branches to local repo I created with all contents.
在此之后,来自远程仓库的内容现在位于我的本地裸仓库中,但是如何获取各个分支的所有远程更改并将其合并到我创建的本地仓库中的相应分支?
我尝试过使用“git remote add”,但它只获取引用,实际上并没有合并内容。
提前感谢您为我提供的任何帮助。
谢谢
【问题讨论】:
-
添加遥控器后你拉了吗?此外,如果您正确配置了遥控器,我相信当您执行“git push”时,所有跟踪的分支都会被同时推送
-
我做了一个拉,但它告诉我配置不正确,推送不起作用,我怎样才能正确设置配置文件,对不起,如果这个问题看起来有点愚蠢,但我是新手混帐。谢谢
标签: git version-control git-merge git-remote