git查看下载的远程源

19 2025-10-22 14:04

在 Git 中,你可以通过以下命令查看当前仓库的远程源(即下载来源):
bash
 
复制
git remote -v
 
这个命令会列出所有远程仓库的名称及其对应的 URL,通常你会看到类似这样的输出:
 
复制
origin  https://github.com/username/repo.git (fetch)
origin  https://github.com/username/repo.git (push)
 
其中:
  • origin 是默认的远程仓库名称;
  • 第一行是用于 fetch(拉取) 的地址;
  • 第二行是用于 push(推送) 的地址。

如果你用的是 GitHub、Gitee 等镜像源

有时候国内用户会使用镜像源(比如清华、中科大、Gitee 等),你可以通过 git remote -v 查看是否指向了这些镜像地址。

示例:查看并确认源

bash
 
复制
$ git remote -v
origin  https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git (fetch)
origin  https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git (push)
 
这说明你是从清华镜像下载的 Linux 内核源码。

小提示

如果你克隆的是 GitHub 仓库,但用的是镜像地址,提交代码时可能需要改回 GitHub 地址才能正常 push:
bash
 
复制
git remote set-url origin https://github.com/username/repo.git
 

全部评论

·