本地GIT存储库在哪里或如何存储GitHub存储库链接或ID?
我有一个本地的Windows Git项目,该项目与GitHub定期同步。我正在使用Visual Studio代码。
我从 ft-db-webapp-service ft-db-tools 重命名为github存储库,而无需在本地做任何事情。
回购URL已从
相应变化 来自:https://github.com/jammusi/ft-db-webapp-service
到:https://github.com/jammusi/ft-db-tools
现在,我进行了一些本地更改,并将它们与Github的云回购同步。这效果很好。与更名的存储库同步的更改。
我试图了解这是如何工作的。并不是说这太奇怪了,但是我确实试图检查本地GIT存储库是如何包含对正确的GitHub repo的。我检查了文件
.git/config
,然后看到了github存储库的链接。
这是之前的文件内容,以及同步之后。
该文件尚未更改,并且仍然包含旧链接。
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://github.com/jammusi/FT-db-webapp-service.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
I have a local windows git project that I'm synching regularly with github. I am working with visual studio code.
I renamed the github repository from FT-db-webapp-service to FT-DB-Tools, without doing anything locally.
the repo url has changed accordingly from
from :https://github.com/jammusi/FT-db-webapp-service
to:https://github.com/jammusi/FT-DB-Tools
Now, I made some local changes and synced them with the cloud repo in github. this worked well. The changes where synched with the renamed repository.
I try to understand how this worked. Not that it is so surprising, but I did try to check how the local git repo holds the reference to the right github repo. I checked the file
.git/config
and I see link to the github repository.
This is the file content before as well as after the synching.
The file has not been changed, and still holds the old link.
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://github.com/jammusi/FT-db-webapp-service.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的当地git没有做任何特别的事情,github是。
Github永远保持您与存储库的旧链接。因此,每次您重命名存储库时,都会添加一个新链接。此功能称为“重定向”,于2013年首次宣布(请参阅: https://github.blog/2013-05-16-repository-redirects-are-here/ )
Your local git is not doing anything special, Github is.
Github maintains your old links to the repository forever. Therefore, every time you rename your repository you are adding a new link to it. This feature is called "redirects" and was first announced in 2013 (see: https://github.blog/2013-05-16-repository-redirects-are-here/)