I'm sure this can be done, i'm just not sure of the right way.
My scenario is to have a USB drive, a local hard drive and a network drive all connected to my PC at this point. The local hard drive will contain the local active repo for my local work. The network drive (with a long UNC path!) would contain the main bare repo that acts as the upstream reference copy (2 or 3 collaborators in the office), while the USB drive acts as my mobile copy for sneakernetting to some external PCs (my other collaborators have their own drives, which may affect answers). (this is on windows msysgit).
It is the setting up of the USB drive that is the concern, and making sure I'm directing the workflow in the right direction (see using-git-on-usb-stick-for-travelling-code .
In order to clone your repository to create a new bare repository, you run the clone command with the --bare option. By convention, bare repository directory names end with the suffix . git , like so: $ git clone --bare my_project my_project.
Navigate to the repository you just cloned. Pull in the repository's Git Large File Storage objects. Mirror-push to the new repository. Push the repository's Git Large File Storage objects to your mirror.
You can simply clone the repository to another directory on the same machine: git clone /bare/repo/dir. The current directory will become a non-bare clone of your repo, and you'll get a checkout of the master branch automatically. Then use the usual commands like git pull to update it as needed.
You can create a bare-to-bare clone from the repo with the long UNC path to the USB stick with
cd /e/src git clone --bare //server/path/to/your/network/repo.git
but I doubt it buys you much to do it in one step.
Given that you'll be working in your local active repo, I'd create a bare repo on the USB stick
cd git init --bare /e/src/myproject.git
create a remote in your local active repo
git remote add usb file:///e/src/myproject.git
and then push to it as necessary.
git push usb philip/cool-new-feature
The commands above assume your USB stick is E: and that your working directory is within your local active repo.
As I understand your question, you have at least two disjoint sets of collaborators, depending on whether your other collaborators share a common central repository of their own or are all working on isolated machines. This means the repository on your USB stick is the repository to which everyone (eventually) has access, so your teammates spend most of their time “on a plane” with respect to it.
Suggestions for designing your development process:
One way you might do this is to have everyone keep a clean master and make changes only on other branches. Physical possession of the USB stick is a natural integration token, so when a given collaborator has it, the sequence goes
git checkout master git pull usb master # should always be a fast-forward git merge feature1 make test # or whatever, and repeat until no breakage git commit git push usb master git push shared master # if appropriate git merge feature2 # if necessary ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With