我在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)

其他回答

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 reflog 显示的最后一个输入)应指明重组原来的位置。

吉。

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

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

我基本上使用:

git remote get-url origin

在 Windows 中,它适用于 Git Bash 命令控制台或 CMD 命令控制台。

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

Git URL 将位于 Git 配置文件中,值相当于关键 URL。

对于 Mac 和 Linux,请使用下面的命令:

cd project_dir
cat .git/config | grep url | awk '{print $3}'

在 Windows 中,在任何文本编辑器中打开下面的文件,并找到关键URL的值。

project_dir/.git/config

注意: 即使您离线或远程 Git 服务器已被删除,这也将工作。