Synchronize work-in-progress git branches in a light weight fashion. Motivation:
Install git-nomad to make it available on your $PATH.
Assume you're hacking away with your usual git workflow:
console
rraval@desktop:~/git-nomad$ git checkout -b feature
rraval@desktop:~/git-nomad$ touch new_file
rraval@desktop:~/git-nomad$ git add .
rraval@desktop:~/git-nomad$ git commit -m "new file"
Whenever you like, you can push the state of your local branches with:
```console
origin by default.--help for overriding this explicitly.rraval@desktop:~/git-nomad$ git nomad sync Pushing local branches to origin... 3s Fetching branches from origin... 0s Listing branches at origin... 3s
desktop refs/nomad/desktop/feature -> c340cd55853339e4d039746495cdb80cd9e46123 refs/nomad/desktop/master -> 267719fb8448cc1cbef2c35a638610573779f2ac ```
At some future point, you wish to pick up development on a different machine:
```console rraval@laptop:~/git-nomad$ git nomad sync Pushing local branches to origin... 2s Fetching branches from origin... 1s Listing branches at origin... 2s
desktop refs/nomad/desktop/feature -> 1a101799507ba67d822b97105aafa0ac91ce5183 refs/nomad/desktop/master -> 267719fb8448cc1cbef2c35a638610573779f2ac laptop refs/nomad/laptop/master -> 267719fb8448cc1cbef2c35a638610573779f2ac ```
Which prints out refs to use to pick up where you left off:
```console rraval@laptop:~/git-nomad$ git checkout -b feature refs/nomad/desktop/feature
```
Let's say that the laptop machine is where development is happening now, so
you go back to desktop to throw away the now outdated branch:
```console rraval@desktop:~/git-nomad$ git checkout master rraval@desktop:~/git-nomad$ git branch -D feature Deleted branch feature (was 1a10179).
rraval@desktop:~/git-nomad$ git nomad sync Pushing local branches to origin... 2s Fetching branches from origin... 1s Listing branches at origin... 0s Pruning branches at origin... 0s Delete refs/nomad/desktop/feature (was 1a101799507ba67d822b97105aafa0ac91ce5183)... 0s
desktop refs/nomad/desktop/master -> 267719fb8448cc1cbef2c35a638610573779f2ac laptop refs/nomad/laptop/feature -> dedf3f9d3ad279a401877b351c3ec13aa47cbbd4 refs/nomad/laptop/master -> 267719fb8448cc1cbef2c35a638610573779f2ac ```
If you'd like to stop using git-nomad and clean up all the refs it has created:
```console
purge --host option.rraval@desktop:~/git-nomad$ git nomad purge --all Fetching branches from origin... 1s Listing branches at origin... 0s Pruning branches at origin... 2s Delete refs/nomad/desktop/master (was 267719fb8448cc1cbef2c35a638610573779f2ac)... 0s Delete refs/nomad/laptop/feature (was dedf3f9d3ad279a401877b351c3ec13aa47cbbd4)... 0s Delete refs/nomad/laptop/master (was 267719fb8448cc1cbef2c35a638610573779f2ac)... 0s ```
Git is unabashedly a content-addressed filesystem that manipulates blob, tree, and commit objects. Layered on top of this is a half decent version control system, though this claim is contentious at best.
Git branches are implemented on top of a more general scheme called refs, where the local branch master is simply the commit pointed to by refs/heads/master. Git reserves a few hierarchies for its own use:
refs/heads/* represent local branches.refs/tags/* represent tags.refs/remotes/* represent remote branches.git-nomad works directly with refs to implement its own light weight synchronization scheme:
refs/heads/* to remote refs/nomad/{user}/{host}/*. This allows multiple users on multiple hosts to all use git-nomad on the same remote without overwriting data.refs/nomad/{user}/* to local refs/nomad/*. This makes all the host refs for a given user available in a local clone.refs/nomad/* refs where the corresponding branch has been deleted.Using refs like this has advantages:
gits automatic garbage collection should reclaim space.refs/nomad hierarchy, they are not subject to the usual fast-forward only rules.Releases on GitHub have prebuilt binary assets: https://github.com/rraval/git-nomad/releases
gunzip the downloaded file.$PATH.git nomad --version.Install via nixpkgs:
$ nix-env --install git-nomad
If you have cargo available:
$ cargo install git-nomad
nix runNix can build and run the binary directly from GitHub via:
$ nix run github:rraval/git-nomad
There are a few ways to make this project better:
-vv flag to capture all information about the commands that were run.