用于提取和推送的远程URL是否会有所不同? [英] Will remote URL for fetch and push be different?

查看:141
本文介绍了用于提取和推送的远程URL是否会有所不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git remote --v显示远程信息

git remote --v show remote info

origin  https://github.com/test/testing-iOS.git (fetch)
origin  https://github.com/test/testing-iOS.git (push)

它表明提取和推送都使用相同的远程URL.

It shows that both fetch and push are using the same remote URL.

问题:

何时(如果有的话)用于提取和推送的远程URL会有所不同?

When will (if ever) remote URL for fetch and push be different?

您可以使用哪些命令来更改远程URL,以分别进行提取或推送?

What commands can you use to change remote URL for fetch or push separately?

推荐答案

是的(使用不同的遥控器),这就是为什么Git 2.5引入了新的ref缩写@{push}的原因. 请参阅"查看未推动的Git提交"

Yes (using different remote), and that is why Git 2.5 introduces a new ref shorthand @{push}.
See "Viewing Unpushed Git Commits"

您可以使用哪些命令来更改远程URL,以分别进行提取或推送?

What commands can you use to change remote URL for fetch or push separately?

您需要一个单独的遥控器:

You need a separate remote:

git remote add myfork /url/for/my/fork
git config remote.pushdefault myfork

GitHub博客文章"@{push}的使用:

The GitHub blog post "Improved support for triangular workflows" illustrates the use of @{push}:

查看自上次推送以来已添加到当前分支中的提交:

See what commits you've added to your current branch since the last push:

git clone https://github.com/YOUR-USERNAME/atom
cd atom
git config remote.pushdefault origin
git config push.default current

  • remote.pushdefault 指定 位置 (要推送到哪个远程仓库).
  • push.default 指定 (当没有明确指定refspec时)推送(什么refspec).
    在后一种情况下,current表示推送当前分支以在接收端更新具有相同名称的分支".
    • remote.pushdefault specifies where to push (to which remote repo).
    • push.default specifies what to push (what refspec), when no refspec is explicitly given.
      current, in that latter case, means "push the current branch to update a branch with the same name on the receiving end."
    • 以下分支将从一个网址获取,然后推送到另一个网址:

      The following branch will fetch from one url, push to another:

      git remote add upstream https://github.com/atom/atom
      git fetch upstream
      git checkout -b whizbang upstream/master
      

      (这里whizbang分支轨道upstream/master,但被推送到origin/whizbang)

      (Here the whizbang branches tracks upstream/master, but pushes to origin/whizbang)

      git log @{push}..
      

      这使用新的@{push}表示法,表示git push将当前分支推送到的远程跟踪分支的当前值,即origin/whizbang.
      您还可以使用符号whizbang@{push}引用任意分支的推送目标.

      This uses the new @{push} notation, which denotes the current value of the remote-tracking branch that the current branch would be pushed to by git push, namely origin/whizbang.
      You can also refer to the push destination of an arbitrary branch using the notation whizbang@{push}.

      这篇关于用于提取和推送的远程URL是否会有所不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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