[英]How to set a git branch to push to a remote with a different branch name and pull from completely different url
我的本地git repo需要从一台服务器中提取。 然后,它需要将特定分支推送到不同服务器上具有不同分支名称的审阅仓库。
诸如此类:从Server1上的PullOnlyRepo中提取所有内容(我们可能称其为起源?)将分支修补程序推送至Server2上具有分支名称JistChanges的ReivewRepo。
现在,git config -l显示:
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=<URL for Server1>
remote.origin.pushurl=no_push (this shouldn't matter since it is a pull only repo)
branch.production.remote=origin
branch.production.merge=refs/heads/production
remote.review.url=<URL for Server2>
remote.review.fetch=+refs/heads/*:refs/remotes/review/*
git pull可以实现我想要的功能(从Server1的正确位置获取更改并将它们合并到我的工作树中)。
但是git push不会。 为了实现我想要的,我必须做的
git push review hotfix:JistChanges
有什么方法可以使git pull做到这一点而不必放入多余的东西吗?
已经设置了一些问题,以便您的本地分支将推送到具有不同分支名称的远程站点。 但是,它们也会改变上游以及拉力的来源。
您可以为hotfix
设置上游分支:
git config push.default upstream
git config push.default review
git branch --set-upstream hotfix review/JistChanges
请参阅“ 如何使现有的git分支跟踪远程分支? ”请参阅默认push
策略上的“ git push origin
的结果是什么? ”(很快就会变得“ simple
”)
从git1.8.0开始:
git branch -u review/JistChanges hotfix
git remote set-url --push origin
git config remote.origin.push refs/heads/hotfix:JistChanges
Ok VonC的回答使我步入正轨。 这是我所做的:
git remote set-url --push origin <review repo URL>
git config remote.origin.push refs/heads/hotfix:JistChanges
唯一的问题是,现在一切都推送到了评论仓库。 现在还可以,因为90%的工作将在此分支中。 其他10%的人可以使用git push进行其他操作,其中其他人使用正确的push配置进行相同的原始回购。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.