fetch 和 push 的 remote URL 会不同吗?
Will remote URL for fetch and push be different?
git 远程 --v 显示远程信息
origin https://github.com/test/testing-iOS.git (fetch)
origin https://github.com/test/testing-iOS.git (push)
这表明 fetch 和 push 都在使用同一个遥控器 URL。
问题:
什么时候(如果有的话)用于获取和推送的远程 URL 会有所不同?
您可以使用哪些命令来更改远程 URL 以单独获取或推送?
是的(使用不同的遥控器),这就是为什么 Git 2.5 引入了一个新的参考 shorthand @{push}
.
参见“Viewing Unpushed Git Commits”
What commands can you use to change remote URL for fetch or push separately?
您需要一个单独的遥控器:
git remote add myfork /url/for/my/fork
git config remote.pushdefault myfork
GitHub 博客post“Improved support for triangular workflows”说明了 @{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
指定where推送(到哪个远程repo) .
push.default
指定什么推送(什么refspec),当没有明确给出 refspec。
current
,在后一种情况下,表示 "push the current branch to update a branch with the same name on the receiving end."
以下分支将从一个 url 获取,推送到另一个:
git remote add upstream https://github.com/atom/atom
git fetch upstream
git checkout -b whizbang upstream/master
(此处 whizbang
分支跟踪 upstream/master
,但推送到 origin/whizbang
)
git log @{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 应该相同。
http://git-scm.com/docs/git-remote
设置推送和获取 url 的命令
'git remote set-url' [--push] <name> <newurl> [<oldurl>]
Note that the push URL and the fetch URL, even though they can be set differently, must still refer to the same place. What you pushed to the push URL should be what you would see if you immediately fetched from the fetch URL. If you are trying to fetch from one place (e.g. your upstream) and push to another (e.g. your publishing repository), use two separate remotes.
git 远程 --v 显示远程信息
origin https://github.com/test/testing-iOS.git (fetch)
origin https://github.com/test/testing-iOS.git (push)
这表明 fetch 和 push 都在使用同一个遥控器 URL。
问题:
什么时候(如果有的话)用于获取和推送的远程 URL 会有所不同?
您可以使用哪些命令来更改远程 URL 以单独获取或推送?
是的(使用不同的遥控器),这就是为什么 Git 2.5 引入了一个新的参考 shorthand @{push}
.
参见“Viewing Unpushed Git Commits”
What commands can you use to change remote URL for fetch or push separately?
您需要一个单独的遥控器:
git remote add myfork /url/for/my/fork
git config remote.pushdefault myfork
GitHub 博客post“Improved support for triangular workflows”说明了 @{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
指定where推送(到哪个远程repo) .push.default
指定什么推送(什么refspec),当没有明确给出 refspec。
current
,在后一种情况下,表示 "push the current branch to update a branch with the same name on the receiving end."
以下分支将从一个 url 获取,推送到另一个:
git remote add upstream https://github.com/atom/atom
git fetch upstream
git checkout -b whizbang upstream/master
(此处 whizbang
分支跟踪 upstream/master
,但推送到 origin/whizbang
)
git log @{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, namelyorigin/whizbang
.
You can also refer to the push destination of an arbitrary branch using the notationwhizbang@{push}
.
根据文档,获取和推送 URL 应该相同。
http://git-scm.com/docs/git-remote
设置推送和获取 url 的命令
'git remote set-url' [--push] <name> <newurl> [<oldurl>]
Note that the push URL and the fetch URL, even though they can be set differently, must still refer to the same place. What you pushed to the push URL should be what you would see if you immediately fetched from the fetch URL. If you are trying to fetch from one place (e.g. your upstream) and push to another (e.g. your publishing repository), use two separate remotes.