{"thread":{"id":"23022","subject":"merging unmanaged working tree","startedAt":"2010-03-15T11:34:14Z","lastAt":"2010-03-15T23:49:10Z","messageCount":9,"participants":["Łukasz Stelmach","Daniel","Avery Pennarun","Chris Packham"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"136827","messageId":"87ljdtkedl.fsf@dasa3.iem.pw.edu.pl","threadId":"23022","inReplyTo":null,"subject":"merging unmanaged working tree","fromName":"Łukasz Stelmach","fromEmail":"lukasz.stelmach@iem.pw.edu.pl","sentAt":"2010-03-15T11:34:14Z","receivedAt":"2010-03-15T11:34:14Z","isPatch":false,"sender":{"key":"lukasz.stelmach@iem.pw.edu.pl","avatar":null},"body":"Hello.\n\nIs there a method to (dry?) run git-merge to detect conflicts\non:\n\n* current HEAD (or working tree)\n* selected previous revision (the one used to \"branch\")\n* directory tree (or a single file) \"branched\" with git-archive\n\nI'd like to synchronize portable working tree but don't want to keep\nhistory in it.\n\n-- \nMiłego dnia,\nŁukasz Stelmach\n"},{"id":"136829","messageId":"46a29168.6d880e7c.4b9e296c.483a1@o2.pl","threadId":"23022","inReplyTo":"87ljdtkedl.fsf@dasa3.iem.pw.edu.pl","subject":"Re: merging unmanaged working tree","fromName":"Daniel","fromEmail":"mjucde@o2.pl","sentAt":"2010-03-15T12:34:52Z","receivedAt":"2010-03-15T12:34:52Z","isPatch":false,"sender":{"key":"mjucde@o2.pl","avatar":null},"body":"> Hello.\n> \n> Is there a method to (dry?) run git-merge to detect conflicts\n> on:\n> \n> * current HEAD (or working tree)\n> * selected previous revision (the one used to \"branch\")\n> * directory tree (or a single file) \"branched\" with git-archive\n> \n> I'd like to synchronize portable working tree but don't want to keep\n> history in it.\n> \n> -- \n> Miłego dnia,\n> Łukasz Stelmach\n> --\n\nDoes \"git-merge --squash\" do what you want? You still need to have\nthe other tree managed by git (even for a while).\n\n-- \nDaniel\n"},{"id":"136832","messageId":"87d3z5k3yb.fsf@dasa3.iem.pw.edu.pl","threadId":"23022","inReplyTo":"46a29168.6d880e7c.4b9e296c.483a1@o2.pl","subject":"Re: merging unmanaged working tree","fromName":"Łukasz Stelmach","fromEmail":"lukasz.stelmach@iem.pw.edu.pl","sentAt":"2010-03-15T15:19:24Z","receivedAt":"2010-03-15T15:19:24Z","isPatch":false,"sender":{"key":"lukasz.stelmach@iem.pw.edu.pl","avatar":null},"body":"Daniel <mjucde@o2.pl> writes:\n\n>> Is there a method to (dry?) run git-merge to detect conflicts\n>> on:\n>> \n>> * current HEAD (or working tree)\n>> * selected previous revision (the one used to \"branch\")\n>> * directory tree (or a single file) \"branched\" with git-archive\n>> \n>> I'd like to synchronize portable working tree but don't want to keep\n>> history in it.\n> Does \"git-merge --squash\" do what you want? You still need to have\n> the other tree managed by git (even for a while).\n\nNot really. Well, what I want is abit odd so let me try another way\n\n1. There is a repository (non-bare one) with all changes\n   commited. Commit A.\n\n2. I take some files put them on my pendrive. I take a note that they come\n   from commit A. I don't clone the repository.\n\n3. I make changes here (in the repository) and commit them (commits B,\n   C, D) and there (on my pendrive).\n\n4. I want to merge things with something like this\n\n$ git diff3 file1.c(D) file1.c(A) /media/project/file1.c\n\n* file1.c(D) is the lates version in my repository and working tree\n* file1.c(A) is the point where I branched\n* /media/project/file1.c is the unmanaged version of the file with changes\n  I made on the go.\n\nDoes git allow to retrieve (to stdout) a particular revision of a single\nfile? If so I could use \"<(git retrieve A file1.c)\" bash trick.\n\nOr (this is my goal) is there another way not to keep the whole history\nof my repository on the pendrive? Just the changes I made since the\nbrnaching point. And then clean (yeah squash, but it's not the same I am\nafraid) everything after merging.\n\n-- \nMiłego dnia,\nŁukasz Stelmach\n"},{"id":"136868","messageId":"32541b131003151222r32244cf4o6182545e3a1eb1aa@mail.gmail.com","threadId":"23022","inReplyTo":"87d3z5k3yb.fsf@dasa3.iem.pw.edu.pl","subject":"Re: merging unmanaged working tree","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-03-15T19:22:16Z","receivedAt":"2010-03-15T19:22:16Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"2010/3/15 Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl>:\n> 1. There is a repository (non-bare one) with all changes\n>   commited. Commit A.\n>\n> 2. I take some files put them on my pendrive. I take a note that they come\n>   from commit A. I don't clone the repository.\n>\n> 3. I make changes here (in the repository) and commit them (commits B,\n>   C, D) and there (on my pendrive).\n>\n> 4. I want to merge things with something like this\n\nYou have a few options that I can think of.\n\na) Look at 'git clone --depth' so you can clone only the most recent\nversion of the files, not the *entire* repo.  This lets you do commits\non any computer you want with the pen drive plugged in, but saves\nspace.\n\nb) Keep your .git directory on your main PC's disk, and the working\ntree on your pen drive.  Look at the GIT_DIR environment variable in\n'man git'.  Then when you bring the pen drive back to your PC, you\nhave the full repo available.  (If you use 'git clone --reference'\nwhen making the new repo, the extra .git directory should take only\nminimal space.)\n\nc) Make a clone of your repo on the PC, then rsync the non-git parts\nof that clone's work tree to and from your pen drive.  (This option is\nthe most error-prone since you have to make sure you never rsync in\nthe wrong direction at the wrong time.  But it's maybe the easiest to\nunderstand.)\n\nHope this helps.\n\nHave fun,\n\nAvery\n"},{"id":"136869","messageId":"a038bef51003151258q2a4ba7dfwe84b29854c03d7eb@mail.gmail.com","threadId":"23022","inReplyTo":"87d3z5k3yb.fsf@dasa3.iem.pw.edu.pl","subject":"Re: merging unmanaged working tree","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2010-03-15T19:58:49Z","receivedAt":"2010-03-15T19:58:49Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"2010/3/15 Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl>:\n> Daniel <mjucde@o2.pl> writes:\n>\n>>> Is there a method to (dry?) run git-merge to detect conflicts\n>>> on:\n>>>\n>>> * current HEAD (or working tree)\n>>> * selected previous revision (the one used to \"branch\")\n>>> * directory tree (or a single file) \"branched\" with git-archive\n>>>\n>>> I'd like to synchronize portable working tree but don't want to keep\n>>> history in it.\n>> Does \"git-merge --squash\" do what you want? You still need to have\n>> the other tree managed by git (even for a while).\n>\n> Not really. Well, what I want is abit odd so let me try another way\n>\n> 1. There is a repository (non-bare one) with all changes\n>   commited. Commit A.\n>\n> 2. I take some files put them on my pendrive. I take a note that they come\n>   from commit A. I don't clone the repository.\n>\n> 3. I make changes here (in the repository) and commit them (commits B,\n>   C, D) and there (on my pendrive).\n>\n> 4. I want to merge things with something like this\n>\n> $ git diff3 file1.c(D) file1.c(A) /media/project/file1.c\n>\n> * file1.c(D) is the lates version in my repository and working tree\n> * file1.c(A) is the point where I branched\n> * /media/project/file1.c is the unmanaged version of the file with changes\n>  I made on the go.\n>\n> Does git allow to retrieve (to stdout) a particular revision of a single\n> file? If so I could use \"<(git retrieve A file1.c)\" bash trick.\n>\n> Or (this is my goal) is there another way not to keep the whole history\n> of my repository on the pendrive? Just the changes I made since the\n> brnaching point. And then clean (yeah squash, but it's not the same I am\n> afraid) everything after merging.\n>\n> --\n> Miłego dnia,\n> Łukasz Stelmach\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\nOne option, assuming you do record \"Commit A\" every time you do this,\nwould be to use a short lived branch to merge your changes back in.\n\ne.g.\n\ngit checkout -b work_from_home <sha of commit a>\ncp /media/... .\ngit status # at this point you can check that what you about to commit\nis what you intended, and\ngit commit -a # if it is good\ngit checkout master\ngit merge work_from_home # this is where any conflicts would be resolved\ngit branch -d work_from_home\n\nThe downside with this is that it is very likely that your files will\npick up an executable bit from the file system on your pen drive which\nwill need to be fixed up before you commit them.\n"},{"id":"136870","messageId":"32541b131003151301i69e5df1doc463406738086a89@mail.gmail.com","threadId":"23022","inReplyTo":"a038bef51003151258q2a4ba7dfwe84b29854c03d7eb@mail.gmail.com","subject":"Re: merging unmanaged working tree","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-03-15T20:01:55Z","receivedAt":"2010-03-15T20:01:55Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"2010/3/15 Chris Packham <judge.packham@gmail.com>:\n> The downside with this is that it is very likely that your files will\n> pick up an executable bit from the file system on your pen drive which\n> will need to be fixed up before you commit them.\n\nIf you have this problem, you might want to look at the core.fileMode\noption.  (See 'man git-config').\n\nHave fun,\n\nAvery\n"},{"id":"136899","messageId":"87iq8xw4fo.fsf@kotik.lan","threadId":"23022","inReplyTo":"a038bef51003151258q2a4ba7dfwe84b29854c03d7eb@mail.gmail.com","subject":"Re: merging unmanaged working tree","fromName":"Łukasz Stelmach","fromEmail":"lukasz.stelmach@iem.pw.edu.pl","sentAt":"2010-03-15T23:28:11Z","receivedAt":"2010-03-15T23:28:11Z","isPatch":false,"sender":{"key":"lukasz.stelmach@iem.pw.edu.pl","avatar":null},"body":"Chris Packham <judge.packham@gmail.com> writes:\n\n> 2010/3/15 Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl>:\n>> 1. There is a repository (non-bare one) with all changes\n>>   commited. Commit A.\n>>\n>> 2. I take some files put them on my pendrive. I take a note that they come\n>>   from commit A. I don't clone the repository.\n>>\n>> 3. I make changes here (in the repository) and commit them (commits B,\n>>   C, D) and there (on my pendrive).\n>>\n>> 4. I want to merge things with something like this\n>>\n>> $ git diff3 file1.c(D) file1.c(A) /media/project/file1.c\n>>\n>> * file1.c(D) is the lates version in my repository and working tree\n>> * file1.c(A) is the point where I branched\n>> * /media/project/file1.c is the unmanaged version of the file with changes\n>>  I made on the go.\n> One option, assuming you do record \"Commit A\" every time you do this,\n> would be to use a short lived branch to merge your changes back in.\n>\n> e.g.\n>\n> git checkout -b work_from_home <sha of commit a>\n> cp /media/... .\n> git status # at this point you can check that what you about to commit\n> is what you intended, and\n> git commit -a # if it is good\n> git checkout master\n> git merge work_from_home # this is where any conflicts would be resolved\n> git branch -d work_from_home\n\nIt seems to be the most obvious and straightforward worflow.\nI keep my x-bits off with proper mount options ;-)\n\nThanks.\n\n\n-- \nMiłego dnia,\nŁukasz Stelmach\n"},{"id":"136900","messageId":"87eijlw4cn.fsf@kotik.lan","threadId":"23022","inReplyTo":"32541b131003151222r32244cf4o6182545e3a1eb1aa@mail.gmail.com","subject":"Re: merging unmanaged working tree","fromName":"Łukasz Stelmach","fromEmail":"lukasz.stelmach@iem.pw.edu.pl","sentAt":"2010-03-15T23:30:00Z","receivedAt":"2010-03-15T23:30:00Z","isPatch":false,"sender":{"key":"lukasz.stelmach@iem.pw.edu.pl","avatar":null},"body":"Avery Pennarun <apenwarr@gmail.com> writes:\n\n> 2010/3/15 Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl>:\n>> 1. There is a repository (non-bare one) with all changes\n>>   commited. Commit A.\n>>\n>> 2. I take some files put them on my pendrive. I take a note that they come\n>>   from commit A. I don't clone the repository.\n>>\n>> 3. I make changes here (in the repository) and commit them (commits B,\n>>   C, D) and there (on my pendrive).\n>>\n>> 4. I want to merge things with something like this\n>\n> You have a few options that I can think of.\n>\n> a) Look at 'git clone --depth' so you can clone only the most recent\n> version of the files, not the *entire* repo.  This lets you do commits\n> on any computer you want with the pen drive plugged in, but saves\n> space.\n\nI've tried this one. It works (but why the --depht 1 gives two\nrevisions?) but even thoug the main repository and the portable one have\ncommon commits I can't pull changes back from the mobile to the main\none. Is there any wise trick to make git try a little harder?\n\n> b) Keep your .git directory on your main PC's disk, and the working\n> tree on your pen drive.  Look at the GIT_DIR environment variable in\n> 'man git'.  Then when you bring the pen drive back to your PC, you\n> have the full repo available.  (If you use 'git clone --reference'\n> when making the new repo, the extra .git directory should take only\n> minimal space.)\n\nThis one's nice and seems to be most space efficient as far as flash\nspace is concerned. However, I'd be able to sync only with the machine\nthat holds the portable GIT_DIR while the previous method, if only\nthere was a way to make git work with shallow clones, could work with\ndifferent hosts if I synec my No1 desktop with them too.\n\n> c) Make a clone of your repo on the PC, then rsync the non-git parts\n> of that clone's work tree to and from your pen drive.  (This option is\n> the most error-prone since you have to make sure you never rsync in\n> the wrong direction at the wrong time.  But it's maybe the easiest to\n> understand.)\n\nDoesn't look good. As easy to under as to mess up.\n\nI've just invented yet another method. Push the content to the pendrive:\n\n$ git commit -am branching\n$ git archive --format tar HEAD | tar -C /media/pendrive/project -xf -\n$ git log -1 > /media/pendrive/project/HEAD # to remember \n\nNow you can make some changes to both the local and the portable copies.\nYou commit the only local changes. Next you retrieve the branching point\ninto a temporary directory\n\n$ git archive --prefix sync-prj/ --format tar \\\n  $(head -1 /media/pendrive/project/HEAD | cut -f 2 -d ' ') | \\\n  tar -C  /tmp -xf -\n\n# run diff3 on ./* /tmp/sync-prj/* /media/pendrive/project/*\n# fix conflicts\n$ git commit -a merged\n\nThe biggest drawback, at the moment, seems to be the fact that I need\nsome space for the branching point archive. And diff3 can't compare\ndirectories like diff -uNr does. But in the end it seems quite robust\nand might actually work with multiple hosts (as long as you can find the\ncommit from /media/pendrive/project/HEAD on each of them).\n\nThanks.\n\n-- \nMiłego dnia,\nŁukasz Stelmach\n"},{"id":"136903","messageId":"32541b131003151649v1a1265f1ke3ccac9cc930f9c8@mail.gmail.com","threadId":"23022","inReplyTo":"87eijlw4cn.fsf@kotik.lan","subject":"Re: merging unmanaged working tree","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-03-15T23:49:10Z","receivedAt":"2010-03-15T23:49:10Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"2010/3/15 Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl>:\n> Avery Pennarun <apenwarr@gmail.com> writes:\n>> a) Look at 'git clone --depth' so you can clone only the most recent\n>> version of the files, not the *entire* repo.  This lets you do commits\n>> on any computer you want with the pen drive plugged in, but saves\n>> space.\n>\n> I've tried this one. It works (but why the --depht 1 gives two\n> revisions?) but even thoug the main repository and the portable one have\n> common commits I can't pull changes back from the mobile to the main\n> one. Is there any wise trick to make git try a little harder?\n\nI don't know; I haven't used shallow clones (ie. --depth) very much.\ngit's implementation of them seems a bit half-hearted.  The man page\nsays \"A shallow repository has a number of limitations (you cannot\nclone or fetch from it, nor push from nor into it), but is adequate if\nyou are only interested in the recent history of a large project with\na long history, and would want to send in fixes as patches.\"  There is\nno technical reason for this limitation, as far as I know.\n\nIt does give a hint as to what you could do instead of push/pulling,\nhowever: you could use git format-patch to extract the changes from\nyour shallow copy, and git am to import the patches back into your\nmain copy.  Seems like a pain though.\n\n>> b) Keep your .git directory on your main PC's disk, and the working\n>> tree on your pen drive.  Look at the GIT_DIR environment variable in\n>> 'man git'.  Then when you bring the pen drive back to your PC, you\n>> have the full repo available.  (If you use 'git clone --reference'\n>> when making the new repo, the extra .git directory should take only\n>> minimal space.)\n>\n> This one's nice and seems to be most space efficient as far as flash\n> space is concerned. However, I'd be able to sync only with the machine\n> that holds the portable GIT_DIR while the previous method, if only\n> there was a way to make git work with shallow clones, could work with\n> different hosts if I synec my No1 desktop with them too.\n\nMaybe you could do something like:\n\n      git clone -s ~/myrepo /pendrive/myrepo\n\nThis will give you a .git dir in /pendrive/myrepo, but all the\n*objects* in the git repo will actually be borrowed from ~/myrepo.\nThis will make git virtually unusable on /pendrive/myrepo *unless* you\nmount the disk on a PC that has ~/myrepo in the original location.  On\nany such computer, you could be able to do normal git operations in\n/pendrive/myrepo, including pulling changes from there to ~/myrepo.\n\nAs you do git operations on /pendrive, /pendrive/myrepo/.git will\nslowly accumulate objects that you might have to clear out over time\n(ie. after pushing them to the parent repo).\n\n> I've just invented yet another method. Push the content to the pendrive:\n>\n> $ git commit -am branching\n> $ git archive --format tar HEAD | tar -C /media/pendrive/project -xf -\n> $ git log -1 > /media/pendrive/project/HEAD # to remember\n> [...]\n\nYeah, I guess you could do that, but at that point you're basically\nnot using git anymore.\n\nHave fun,\n\nAvery\n"}]}