我在GitHub上拖了一個有幾個福克的項目,但忘記了它是哪個福克。


当前回答

要总结一下,至少有四种方式:

使用官方 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/config 文件:

cat .git/config

编辑:

vim.git/config 或

纳米.git/config

对于我来说,这就是最简单的方式(少打字):

git remote -v

出口:

origin    https://github.com/torvalds/linux.git (fetch)
origin    https://github.com/torvalds/linux.git (push)

事实上,我把它放在一个名为 s 的 alias 中,它:

git remote -v
git status

您可以添加到您的个人资料:

alias s='git remote -v && git status'

简短答案:

$ git remote show -n origin

或者,一个纯粹的快速脚本的替代品:

$ git config --get remote.origin.url

一些信息:

你想要起源正确吗? $ git 远程显示起源更好,只显示起源,但需要太长时间(测试在 git 版本 1.8.1.msysgit.1)。

我结束了: $ git 远程显示 -n 起源,似乎是最快的. 与 -n 它不会捕捉远程头(AKA 分支)。 你不需要这种类型的信息,对吗?

http://www.kernel.org/pub//software/scm/git/docs/git-remote.html

您可以在所有 3 个版本中使用 <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk> <unk>

如果你需要纯粹的速度,那么使用:

$ git config --get remote.origin.url

谢谢 @Jefromi 提到这一点。

git remote get-url origin

(Git 远程设置 URL 起源 <newurl>)

See commit 96f78d3 (2015 年 9 月 16 日) by Ben Boeckel (mathstuf). (Merged by Junio C Hamano -- gitster -- in commit e437cbd, 2015 年 10 月 5 日):

远程: 添加 Get-url 子命令 扩展代替Of 是 ls-remote --url 的部分,并且没有办法扩展 pushInsteadOf 也。

get-url:

将 URL 转移到远程. 设置为替代Of 和 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]

要补充其他答案:如果远程因某种原因已被更改,因此不反映原来的起源,则重组中的第一个输入(即由命令 git reflog 显示的最后一个输入)应指明重组原来的位置。

吉。

$ git reflog | tail -n 1
f34be46 HEAD@{0}: clone: from https://github.com/git/git
$

(请记住,返回可以被清理,所以这不保证工作。