How to use tsrc to manage multiple git repositories and remotes
— Albert De La Fuente VigliottiInstall the package #
pip install --user tsrcCreate the manifest repository #
- Create a new repository named
manifest - Create a file
manifest.ymlwith the following content:
repos:
- dest: org
branch: master
remotes:
- name: origin
url: [email protected]:<user>/<repo>.git
- name: https
url: https://<user>:<token>@github.com/<organization>/<repo>.git
- name: nas
url: ssh://<user>@<server>:<port>/<path>/<repo>.gitThis will create the setup for a repository that always stays in sync across all the remotes. The cool thing about this is that it will automatically keep in sync the git remotes with this definition. I have been looking out for this for a long time, this is really cool.
Init the repository and sync #
cd ~
tsrc init [email protected]:<user>/manifest.git
tsrc --verbose syncSync via https #
tsrc --verbose sync -r httpsMigrating from master to main branch #
- Make sure the
masterbranch is clean and there is nothing to commit nor staged - Change to the main branch with
git checkout --track origin/main - Remove the readme if needed
rm README.md - Merge with
git merge --allow-unrelated-histories master - Add the changes
git add . - Commit
git commit -m 'Merge with master branch' - Push
git push - Delete the master branch locally
git branch -d master - Delete the master branch remotely
git push origin --delete master - Change
branch: mastertobranch: mainin themanifest.ymlfile - Commit and push the
manifest.ymlfile
Sometimes it is needed to git branch --set-upstream-to=origin/master master
Sync a group #
This command works and will sync the org-media content (it will create the repo
if it doesn’t exists). However I am not sure I understand why the -r org flag
is needed. The status command instead of sync is useful for debugging.
tsrc --verbose sync -r nas --group org-group -r orgResources #
tsrc documentation #
- Source: https://your-tools.github.io/tsrc/#tutorial
- Title: tsrc documentation
- Captured on: