git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: merging unmanaged working tree

From
Avery Pennarun <apenwarr@gmail.com>
Date
Mar 15, 2010, 23:49 UTC
Message-ID
<32541b131003151649v1a1265f1ke3ccac9cc930f9c8@mail.gmail.com>
In-Reply-To
<87eijlw4cn.fsf@kotik.lan>
2010/3/15 Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl>:
Show 10 quoted lines
> Avery Pennarun <apenwarr@gmail.com> writes:
>> 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.

Show 12 quoted lines
>> 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).

Show 6 quoted lines
> 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
Previous: Łukasz StelmachNext: Chris Packham
Message 6 of 9 in “merging unmanaged working tree”
  1. Łukasz StelmachMar 15, 2010
  2. DanielMar 15, 2010
  3. Łukasz StelmachMar 15, 2010
  4. Avery PennarunMar 15, 2010
  5. Łukasz StelmachMar 15, 2010
  6. Avery PennarunMar 15, 2010
  7. Chris PackhamMar 15, 2010
  8. Avery PennarunMar 15, 2010
  9. Łukasz StelmachMar 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.