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


当前回答

你用SSH克隆来克隆你的存储库。

git config --get remote.origin.url
git@gitlab.com:company/product/production.git

但是,您想要在浏览器中打开或分享一个 HTTP URL:

git config --get remote.origin.url | sed -e 's/:/\//g'| sed -e 's/ssh\/\/\///g'| sed -e 's/git@/https:\/\//g'

https://gitlab.com/company/product/production.git

GitHub 或 GitLab 不重要。

其他回答

简短答案:

$ 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 提到这一点。

alias git-repo="git config --get remote.origin.url | sed -e 's/:/\//g'| sed -e 's/ssh\/\/\///g'| sed -e 's/git@/https:\/\//g'"
alias git-pr="git config --get remote.origin.url | sed -e 's/:/\//g'| sed -e 's/ssh\/\/\///g'| sed -e 's/git@/https:\/\//g' | sed 's/....$//' | sed -ne 's/$/\/pulls &/p'"

在主目录中将此表达式添加到.zshrc 或.bashrc 文件中。

在此之后,您可以使用如

git-repo
git-pr

一个简单的方式是打开.git/config 文件:

cat .git/config

编辑:

vim.git/config 或

纳米.git/config

这只提供URL,这对脚本目的有用:

git config --get remote.origin.url

获取原产地的 IP 地址/主机名称

对于 ssh:// 存储库:

git ls-remote --get-url origin | cut -f 2 -d @ | cut -f 1 -d "/"

關於 git:// repositories:

git ls-remote --get-url origin | cut -f 2 -d @ | cut -f 1 -d ":"