Re: merging unmanaged working tree
From: Avery Pennarun <hidden>
Date: 2016-06-15 22:48:26
2010/3/15 Łukasz Stelmach [off-list ref]:
Avery Pennarun [off-list ref] writes:quoted
a) Look at 'git clone --depth' so you can clone only the most recent version of the files, not the *entire* repo. This lets you do commits on any computer you want with the pen drive plugged in, but saves space.I've tried this one. It works (but why the --depht 1 gives two revisions?) but even thoug the main repository and the portable one have common commits I can't pull changes back from the mobile to the main one. Is there any wise trick to make git try a little harder?
I don't know; I haven't used shallow clones (ie. --depth) very much. git's implementation of them seems a bit half-hearted. The man page says "A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches." There is no technical reason for this limitation, as far as I know. It does give a hint as to what you could do instead of push/pulling, however: you could use git format-patch to extract the changes from your shallow copy, and git am to import the patches back into your main copy. Seems like a pain though.
quoted
b) Keep your .git directory on your main PC's disk, and the working tree on your pen drive. Look at the GIT_DIR environment variable in 'man git'. Then when you bring the pen drive back to your PC, you have the full repo available. (If you use 'git clone --reference' when making the new repo, the extra .git directory should take only minimal space.)This one's nice and seems to be most space efficient as far as flash space is concerned. However, I'd be able to sync only with the machine that holds the portable GIT_DIR while the previous method, if only there was a way to make git work with shallow clones, could work with different hosts if I synec my No1 desktop with them too.
Maybe you could do something like:
git clone -s ~/myrepo /pendrive/myrepo
This will give you a .git dir in /pendrive/myrepo, but all the
*objects* in the git repo will actually be borrowed from ~/myrepo.
This will make git virtually unusable on /pendrive/myrepo *unless* you
mount the disk on a PC that has ~/myrepo in the original location. On
any such computer, you could be able to do normal git operations in
/pendrive/myrepo, including pulling changes from there to ~/myrepo.
As you do git operations on /pendrive, /pendrive/myrepo/.git will
slowly accumulate objects that you might have to clear out over time
(ie. after pushing them to the parent repo).
I've just invented yet another method. Push the content to the pendrive: $ git commit -am branching $ git archive --format tar HEAD | tar -C /media/pendrive/project -xf - $ git log -1 > /media/pendrive/project/HEAD # to remember [...]
Yeah, I guess you could do that, but at that point you're basically not using git anymore. Have fun, Avery