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


当前回答

我更喜欢这个,因为更容易记住:

git config -l

它将列出所有有用的信息,如:

user.name=Your Name
user.email=your.name@notexisting.com
core.autocrlf=input
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/mapstruct/mapstruct-examples
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

其他回答

使用 git 远程显示起源,您必须在项目目录中,但如果您想从其他地方确定 URL 您可以使用:

cat <path2project>/.git/config | grep url

如果您需要这个命令经常,您可以在 MacOS 中的.bashrc 或.bash_profile 中定义一个 alias。

alias giturl='cat ./.git/config | grep url'

因此,您只需要在 Git 根文件夹中呼叫 giturl 以便简单地获得其 URL。


如果你延伸这个 alias 如此

alias giturl='cat .git/config | grep -i url | cut -d'=' -f 2'

你只得到平坦的URL没有先前的

“URL”

url=http://example.com/repo.git

您在使用中获得更多机会:

例子

在 Mac 上,您可以打开 $(giturl) 以在默认浏览器中打开 URL。

或Chrome $(giturl)在Linux上使用Chrome浏览器打开它。

只需使用此命令在您的.git 文件夹的位置:

git config --get remote.origin.url

如果你连接到一个网络,

git remote show origin

它将向您显示一个本地Git存储库原来被克隆的URL。

打印自愿命名的远程 fetch URL:

git remote -v | grep fetch | awk '{print $2}'

我认为你可以找到它在.git/config 和远程[“起源”] 如果你没有操纵它。

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]