几天前我从GitHub上撤了一个项目。我已经发现GitHub上有几个叉子,我忽略了我最初使用的那个。如何确定我拉出的哪个叉子?
几天前我从GitHub上撤了一个项目。我已经发现GitHub上有几个叉子,我忽略了我最初使用的那个。如何确定我拉出的哪个叉子?
如果只想要远程URL,或者参照完整性已被破坏:
git config --get remote.origin.url
如果您需要完整输出或参照完整性完好无损:
git remote show origin
使用时 git clone
(来自GitHub,或任何源存储库)克隆源的默认名称是“origin”。运用 git remote show
将显示有关此远程名称的信息。前几行应显示:
C:\Users\jaredpar\VsVim> git remote show origin
* remote origin
Fetch URL: git@github.com:jaredpar/VsVim.git
Push URL: git@github.com:jaredpar/VsVim.git
HEAD branch: master
Remote branches:
如果要使用脚本中的值,可以使用此答案中列出的第一个命令。
如果您希望将其用于脚本编写目的,则只能获取URL
git config --get remote.origin.url
你可以试试:
git remote -v
它将打印所有遥控器的提取/推送URL。
得到答案:
git ls-remote --get-url [REMOTE]
这比阅读配置更好;参考 手册页 git-ls-remote
:
--get-URL
考虑到扩展给定远程存储库的URL 任何
"url.<base>.insteadOf"
配置设置(见git-config(1)
)和 退出而不与遥控器通话。
使用Git 2.7(2015年1月5日发布),您可以使用更加一致的解决方案 git remote
:
git remote get-url origin
(漂亮的吊坠 git remote set-url origin <newurl>
)
看到 提交96f78d3 (2015年9月16日)by Ben Boeckel(mathstuf
)。
(合并 Junio C Hamano - gitster
- 在 提交e437cbd,2015年10月5日):
remote:添加get-url子命令
扩大
insteadOf
是的一部分ls-remote --url
而且没有办法 扩大pushInsteadOf
同样。
添加一个get-url
子命令既可以查询,也可以获取所有已配置的URL。
get-url:
检索远程的URL。
的配置insteadOf
和pushInsteadOf
在这里扩展。
默认情况下,仅列出第一个URL。
- 随着''
--push
',查询推送URL而不是获取URL。- 随着''
--all
',将列出遥控器的所有URL。
在git 2.7之前,你有:
git config --get remote.[REMOTE].url
git ls-remote --get-url [REMOTE]
git remote show [REMOTE]
总而言之,至少有四种方式:
(以下是针对官方Linux存储库的尝试)
最少信息:
$ git config --get remote.origin.url
https://github.com/torvalds/linux.git
和
$ git ls-remote --get-url
https://github.com/torvalds/linux.git
更多信息:
$ git remote -v
origin https://github.com/torvalds/linux.git (fetch)
origin https://github.com/torvalds/linux.git (push)
更多信息:
$ git remote show origin
* remote origin
Fetch URL: https://github.com/torvalds/linux.git
Push URL: https://github.com/torvalds/linux.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
简短回答:
$ git remote show -n origin
或者,纯粹快速脚本的替代方案:
$ git config --get remote.origin.url
一些信息:
$ git remote -v
将打印所有遥控器(不是你想要的)。你想要出身吗?$ git remote show origin
更好,只显示 origin
但需要太长时间(在git版本1.8.1.msysgit.1上测试)。我结束了: $ git remote show -n origin
,这似乎是最快的。同 -n
它不会获取远程头(AKA分支)。你不需要那种类型的信息,对吗?
http://www.kernel.org/pub//software/scm/git/docs/git-remote.html
你可以申请 | grep -i fetch
所有三个版本只显示获取URL。
如果您需要纯粹的速度,那么使用:
$ git config --get remote.origin.url
谢谢 @Jefromi 指出这一点。