我在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 ) 之前没有文档。

其他回答

获取原产地的 IP 地址/主机名称

对于 ssh:// 存储库:

git ls-remote --get-url origin | cut -f 2 -d @ | cut -f 1 -d "/"

關於 git:// repositories:

git ls-remote --get-url origin | cut -f 2 -d @ | cut -f 1 -d ":"

只需获取远程URL:

git config --get remote.origin.url

如果您需要完整的输出,并且您正在网络上,可以到达原产地的远程雷波:

git remote show origin

当使用 git clone (从 GitHub,或任何源存储器为该材料) 的默认名称为 clone 的来源是“起源”。使用 git 远程显示将显示有关这个远程名称的信息。

C:\Users\jaredpar\VsVim> git remote show origin
* remote origin
  Fetch URL: git@github.com:jaredpar/VsVim.git
  Push  URL: git@github.com:jaredpar/VsVim.git
  HEAD branch: master
  Remote branches:

如果你想在脚本中使用值,你会使用这个答案中列出的第一个命令。

#!/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/config 和远程[“起源”] 如果你没有操纵它。

打印自愿命名的远程 fetch URL:

git remote -v | grep fetch | awk '{print $2}'