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

其他回答

此将打印您的所有远程的Fetch/Push URL:

git remote -v
git config --list

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

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

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

要总结一下,至少有四种方式:

使用官方 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)