35 lines
2.0 KiB
Markdown
35 lines
2.0 KiB
Markdown
|
|
# How I use Git
|
|
|
|
I host a few `git` repositories on my own personal `gitea` instance. The ones I use the most are...
|
|
|
|
- `bin`, for my scripts (including my `.bash_profile` script
|
|
- `cfg`, for my configuration files
|
|
- `Notes`, or my Obsidian notes
|
|
- `Orchestration`, for my container and virtual machine solutions
|
|
|
|
There are also a few projects that I build myself...
|
|
|
|
- `neovim`
|
|
- `multibg-wayland`
|
|
|
|
Anyway, there's lots more repositories and not all of them are required on all of my machines. While i'm working on a machine i'll make changes in oneor many repositories, so before I shut that machine down i need to `git add`, `git commit` and `git push`.
|
|
|
|
# How This Script Helps
|
|
|
|
In my `.bash_profile` script i set the environment variable `REPO_CFG` to point to my `repo.yaml` file (which is in my `cfg` repository by the way). I also add this `jdownie/repo` folder to my `PATH`. There is an example of a `repo.yaml` in this folder. For each repository, there's a code, a url and a local path to clone the repository into. There's also a list of hostnames that the repository is wanted on (which can be an empty list if the repository is wanted on all hosts; like `bin` and `cfg` for example).
|
|
|
|
With all of that in place, i can run the following commands across all of my repositories...
|
|
|
|
- `repo status`, list each repo with a count of "dirty" files against each
|
|
- `repo lc`, stage and commit all files in each repo with a generic comment
|
|
- `repo fetch`, `repo pull` and `repo push`
|
|
- `repo sync`, pulls and pushes all repositories
|
|
|
|
This script makes it easy for me to run `repo lc` and `repo sync` before i shut a machine down. On my next machine I can run `repo sync` to get my changes on the new machine.
|
|
|
|
If I want to remove a repo from a host. I can remove the hostname from that repositorie's `hosts` list. Then i run `repo prune` which does a `lc`, a `sync` and then removes the cloned folder.
|
|
|
|
Alternatively, i might move a repository. I change the url in `repo.yaml`, and then run `repo align` to update that repository's remote url.
|
|
|