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


当前回答

要得到答案:

git ls-remote --get-url [REMOTE]

這比閱讀配置更好;引用 git-ls-remote 的男性頁面:

--get-url 将该远程存储库的 URL 扩展,考虑到任何“url.<base>.insteadOf”配置设置(见 git-config(1)),并将其输出而不与远程存储库进行谈话。

正如 @Jefromi 指出的那样,此选项在 v1.7.5 中添加,并且直到 v1.7.12.2 (2012-09 ) 之前没有文档。

其他回答

git config --list

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

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

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

git remote -v
#!/bin/bash

git-remote-url() {
 local rmt=$1; shift || { printf "Usage: git-remote-url [REMOTE]\n" >&2; return 1; }
 local url

 if ! git config --get remote.${rmt}.url &>/dev/null; then
  printf "%s\n" "Error: not a valid remote name" && return 1
  # Verify remote using 'git remote -v' command
 fi

 url=`git config --get remote.${rmt}.url`

 # Parse remote if local clone used SSH checkout
 [[ "$url" == git@* ]] \
 && { url="https://github.com/${url##*:}" >&2; }; \
 { url="${url%%.git}" >&2; };

 printf "%s\n" "$url"
}

使用:

# Either launch a new terminal and copy `git-remote-url` into the current shell process, 
# or create a shell script and add it to the PATH to enable command invocation with bash.

# Create a local clone of your repo with SSH, or HTTPS
git clone git@github.com:your-username/your-repository.git
cd your-repository

git-remote-url origin

出口:

https://github.com/your-username/your-repository

要得到答案:

git ls-remote --get-url [REMOTE]

這比閱讀配置更好;引用 git-ls-remote 的男性頁面:

--get-url 将该远程存储库的 URL 扩展,考虑到任何“url.<base>.insteadOf”配置设置(见 git-config(1)),并将其输出而不与远程存储库进行谈话。

正如 @Jefromi 指出的那样,此选项在 v1.7.5 中添加,并且直到 v1.7.12.2 (2012-09 ) 之前没有文档。