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


当前回答

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

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'

其他回答

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

git config --get remote.origin.url
git config --list

此命令将提供与您的存储库相关的所有信息。

上流的远程可能不会被称为“起源”,所以这里有一个变量:

remote=$(git config --get branch.master.remote)
url=$(git config --get remote.$remote.url)
basename=$(basename "$url" .git)
echo $basename

或:

basename $(git config --get remote.$(git config --get branch.master.remote).url) .git

对于更有用的变量,有:

$ git config -l

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

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