当我运行以下命令时:
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 的效果是当您尝试执行push
、pull
和fetch
等操作时。它将查看远程存储库以查看您是否已过期,或者尝试将本地分支推送到分支的远程版本。
关于git - 命令 `git remote add` 在哪里进行更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39907082/