Home > Back-end >  where or how does local git repository store the github repository link or id?
where or how does local git repository store the github repository link or id?

Time:07-06

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

CodePudding user response:

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/)

  • Related