使用一个遥控器拉动,另一个使用Git推动 [英] Use one remote for pulling and another for pushing using Git

查看:58
本文介绍了使用一个遥控器拉动,另一个使用Git推动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对git感到非常舒服,但是我碰到了让我感到困惑的东西。我们在这里使用本地镜子,因为我们的线路很慢。为了指向镜像,我在 .gitconfig 中有常用的东西。



问题出现在我想要推。看起来,我需要一个别名URL作为repo - 而不是重映射到 .gitconfig —或者我需要编辑 .gitconfig code>推到真正的仓库(而不是镜子)。



这真的必须是一个使用模式。我怎样才能使镜子无缝拉动,并在推送时避开它?

解决方案

我有一个很好的解决方法这个!对于Matthew McCullough来说,这个帽子的提示。



事实证明,GIT_CONFIG env变量没有任何影响,无论文档如何描述。另一方面,HOME env变量是git查找.gitconfig的目录的名称。如果你在git命令行中定义了HOME,像这样:

HOME =〜/ somewhere git ...



... git会从.gitconfig目录下的〜/ somewhere中获得它的配置,如果这个gitconfig没有重写URL来指向镜像中的git,那么你正在与原点对话,你可以做到这一点在一个别名...


I'm getting pretty comfortable with git but I've hit something that puzzles me. We use a local mirror, here, because we have a slow line. In order to point at the mirror, I have the usual stuff in .gitconfig.

The problem comes when I want to push. It appears that either I need an alias URL for the repo—not the one remapped in .gitconfig—or I need to edit .gitconfig to push to the real repo (not the mirror).

This really has to be a use pattern. How can I make the mirror seamless on pull and get it out of the way on push?

解决方案

I have a great workaround for this! Tip of the hat to Matthew McCullough.

It turns out that the GIT_CONFIG env variable has no affect, regardless of what the documentation says. On the other hand, the HOME env variable is the name of the directory in which git looks for .gitconfig. If you define HOME in the git command line, like so:

HOME=~/somewhere git ...

... git will obtain its configuration from the .gitconfig is found in the directory "~/somewhere. If that gitconfig does not rewrite URLs to point git at a mirror, you are talking to the origin. You can probably do it in an alias...

这篇关于使用一个遥控器拉动,另一个使用Git推动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆