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


当前回答

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

git config --get remote.origin.url

其他回答

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

cat .git/config

编辑:

vim.git/config 或

纳米.git/config

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

git config --get remote.origin.url

如果你连接到一个网络,

git remote show origin

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

你用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 不重要。

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

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

git config --get remote.origin.url