AkashRajpurohit / git-sync

🔄 A simple tool to backup and sync your git repositories
https://github.com/AkashRajpurohit/git-sync/wiki
MIT License
116 stars 7 forks source link

Git remotes management #53

Open jbonadiman opened 22 hours ago

jbonadiman commented 22 hours ago

Describe the feature or enhancement

Right now, git-sync clones a repository with the default remote using the current information from the config (token, server...), but never updates this information. If for instance, the token I originally used gets expired or if I choose to fork my repository to another instance/service (even though the commit history is the same), I'll have errors. In summary, we could say that git-sync doesn't keep the repositories updated with the config file as it changes.

One way I thought about handling this, is git-sync updating/creating a specific remote to use with its operations (could be named git-sync or something else, just to not fall under the default "origin"), and always keep this remote in sync with the config file as a pre-task before any operation. So if I have a config setup with GitHub, git-sync would check if I have the repository cloned (the "folder exists" check, like nowadays) then it would upsert the remote it manages, creating or updating the remote as needed (but if there's a way to supply the remote as an argument to every git command, I think this works too and might be even better). If in the next run of git-sync, tokens have changed or I changed my client to Bitbucket, since git-sync will always as a pre-task upsert the remote, the sync would run successfully and get the config change without needing to sync from scratch again (of course, if the username changes, I think it should be considered as a different config and so, sync from scratch, since it's part of the repository "full name").

AkashRajpurohit commented 7 hours ago

Linking to the previous discussion regarding this: https://github.com/AkashRajpurohit/git-sync/issues/42#issuecomment-2386517392