本地GIT存储库在哪里或如何存储GitHub存储库链接或ID?

发布于 2025-02-13 13:40:57 字数 964 浏览 2 评论 0原文

我有一个本地的Windows Git项目,该项目与GitHub定期同步。我正在使用Visual Studio代码。

  1. 我从 ft-db-webapp-service ft-db-tools 重命名为github存储库,而无需在本地做任何事情。

    回购URL已从
    相应变化 来自:https://github.com/jammusi/ft-db-webapp-service
    到:https://github.com/jammusi/ft-db-tools

  2. 现在,我进行了一些本地更改,并将它们与Github的云回购同步。这效果很好。与更名的存储库同步的更改。

  3. 我试图了解这是如何工作的。并不是说这太奇怪了,但是我确实试图检查本地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.

  1. 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

  2. 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.

  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁把谁当真 2025-02-20 13:40:57

您的当地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/)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文