git - 命令 `git remote add` 在哪里进行更改?

标签 git git-remote

当我运行以下命令时:

git remote add origin <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9dfaf4e9ddfaf4e9f5e8ffb3fef2f0" rel="noreferrer noopener nofollow">[email protected]</a>:MyName/MyRepo.git

首先,哪些文件被更改?它是我将存储库克隆到的本地树底部的 .git/ 目录中的某个文件吗?

其次,如果我将存储库克隆到另一台计算机上,remote add 命令是否会被记住?还是必须再次运行?

最佳答案

命令git remote add正在指定远程存储库。这将在文件 .git/config 中可见。现在它会有一行类似

[remote "origin"]
    url = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="55323c2115323c213d20377b363a38" rel="noreferrer noopener nofollow">[email protected]</a>:MyName/MyRepo.git
    fetch = +refs/heads/*:refs/remotes/origin/*

这只会影响您的本地克隆。

设置 Remote 的效果是当您尝试执行pushpullfetch等操作时。它将查看远程存储库以查看您是否已过期,或者尝试将本地分支推送到分支的远程版本。

关于git - 命令 `git remote add` 在哪里进行更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39907082/

相关文章:

git - git remote add 和 git clone 的区别

python - 使用 gitpython lib 在 python 脚本中运行时 git pull 命令失败,但直接通过 shell 运行时成功。

git - 应用标签触发构建

git - 始终推送到远程的不同分支,而不设置上游

使用 GitPython 的 git archive --remote 命令

git - 我如何 git remote prune 只是一个特定的远程分支?

linux - 在 GitHub 上添加了 BitBucket 存储库作为远程版本

git - 在 super 项目中自动提交 git 子模块哈希

git - 我如何在 git GUI 中使用 git pull --rebase

git - 将 git repo 克隆到一个非空文件夹