{"thread":{"id":"28886","subject":"Checkout first version of each file?","startedAt":"2011-11-08T13:58:05Z","lastAt":"2011-11-08T18:49:15Z","messageCount":8,"participants":["Dario Rodriguez","Fredrik Gustafsson","Junio C Hamano","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"179135","messageId":"CABLeVKF5P_sWwNX+OR_FX4+SPCN+SovZ2QuMmGGvJ-EskK7=YQ@mail.gmail.com","threadId":"28886","inReplyTo":null,"subject":"Checkout first version of each file?","fromName":"Dario Rodriguez","fromEmail":"soft.d4rio@gmail.com","sentAt":"2011-11-08T13:58:05Z","receivedAt":"2011-11-08T13:58:05Z","isPatch":false,"sender":{"key":"soft.d4rio@gmail.com","avatar":"https://gravatar.com/avatar/9bca8035ad520a6fc0eb66e5126adbe45992c8388c05d1f7952bd4793eb82c22?d=mp&s=160"},"body":"Hello,\n\nMy \"issue\" comes with my usage of git at work. I work with lots of\napplications, each of them part of each system. There are lots of\nprocesses and lots of subsystems, so I never clone the entire repo\ninto GIT, since it could be painful and slow. Even if I do so,\neveryone else is using ClearCase, and their changes cannot be included\ninto my git repo until they \"chickin\". Sometimes, I must update\nsources from FTP because the changes are not up to date in\nClearCase...\n\nSo, I clone every file that I will need to work into GIT, so i can\nwork with these files having a better control (With ClearCase it's a\nfoolish \"checkout>>lots of changes>>checkin\" flow). But sometimes I\ndon't know how many files I am going to change until I start coding\nthe requisites.\n\nIn this cases, there is a situation that I don't know how to handle.\nIf I need to rollback every change made to every file I cannot just\ncheckout the initial commit, cause I've added files after that, and I\nneed their initial versions too.\n\nSo, how can I checkout the first version of each file? (I know that\nGIT tracks contents and not files, but the fact is that I need to keep\ntrack on files, it's the real thing I work with)\n\npd: Sorry about my Argentinian-English (if it sounds so)\n\nThanks,\nDario\n"},{"id":"179136","messageId":"20111108140243.GA4866@kolya","threadId":"28886","inReplyTo":"CABLeVKF5P_sWwNX+OR_FX4+SPCN+SovZ2QuMmGGvJ-EskK7=YQ@mail.gmail.com","subject":"Re: Checkout first version of each file?","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2011-11-08T14:02:43Z","receivedAt":"2011-11-08T14:02:43Z","isPatch":false,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"On Tue, Nov 08, 2011 at 10:58:05AM -0300, Dario Rodriguez wrote:\n> Hello,\n> \n> My \"issue\" comes with my usage of git at work. I work with lots of\n> applications, each of them part of each system. There are lots of\n> processes and lots of subsystems, so I never clone the entire repo\n> into GIT, since it could be painful and slow. Even if I do so,\n> everyone else is using ClearCase, and their changes cannot be included\n> into my git repo until they \"chickin\". Sometimes, I must update\n> sources from FTP because the changes are not up to date in\n> ClearCase...\n> \n> So, I clone every file that I will need to work into GIT, so i can\n> work with these files having a better control (With ClearCase it's a\n> foolish \"checkout>>lots of changes>>checkin\" flow). But sometimes I\n> don't know how many files I am going to change until I start coding\n> the requisites.\n> \n> In this cases, there is a situation that I don't know how to handle.\n> If I need to rollback every change made to every file I cannot just\n> checkout the initial commit, cause I've added files after that, and I\n> need their initial versions too.\n> \n> So, how can I checkout the first version of each file? (I know that\n> GIT tracks contents and not files, but the fact is that I need to keep\n> track on files, it's the real thing I work with)\n> \n> pd: Sorry about my Argentinian-English (if it sounds so)\n> \n> Thanks,\n> Dario\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\nIs all files present in your latest commit? Or can there be deleted\nfiles that you also need to recover?\n\n-- \nMed vänliga hälsningar\nFredrik Gustafsson\n\nE-post: iveqy@iveqy.com\nTel. nr.: 0733 60 82 74\n"},{"id":"179137","messageId":"CABLeVKFkSP=2-kwsN4N+oLrPnijkpvV8Ki=Si4dpYXdzc+8ibQ@mail.gmail.com","threadId":"28886","inReplyTo":"20111108140243.GA4866@kolya","subject":"Re: Checkout first version of each file?","fromName":"Dario Rodriguez","fromEmail":"soft.d4rio@gmail.com","sentAt":"2011-11-08T14:17:27Z","receivedAt":"2011-11-08T14:17:27Z","isPatch":false,"sender":{"key":"soft.d4rio@gmail.com","avatar":"https://gravatar.com/avatar/9bca8035ad520a6fc0eb66e5126adbe45992c8388c05d1f7952bd4793eb82c22?d=mp&s=160"},"body":"On Tue, Nov 8, 2011 at 11:02 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:\n> On Tue, Nov 08, 2011 at 10:58:05AM -0300, Dario Rodriguez wrote:\n>> Hello,\n>>\n>> My \"issue\" comes with my usage of git at work. I work with lots of\n>> applications, each of them part of each system. There are lots of\n>> processes and lots of subsystems, so I never clone the entire repo\n>> into GIT, since it could be painful and slow. Even if I do so,\n>> everyone else is using ClearCase, and their changes cannot be included\n>> into my git repo until they \"chickin\". Sometimes, I must update\n>> sources from FTP because the changes are not up to date in\n>> ClearCase...\n>>\n>> So, I clone every file that I will need to work into GIT, so i can\n>> work with these files having a better control (With ClearCase it's a\n>> foolish \"checkout>>lots of changes>>checkin\" flow). But sometimes I\n>> don't know how many files I am going to change until I start coding\n>> the requisites.\n>>\n>> In this cases, there is a situation that I don't know how to handle.\n>> If I need to rollback every change made to every file I cannot just\n>> checkout the initial commit, cause I've added files after that, and I\n>> need their initial versions too.\n>>\n>> So, how can I checkout the first version of each file? (I know that\n>> GIT tracks contents and not files, but the fact is that I need to keep\n>> track on files, it's the real thing I work with)\n>>\n>> pd: Sorry about my Argentinian-English (if it sounds so)\n>>\n>> Thanks,\n>> Dario\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> Is all files present in your latest commit? Or can there be deleted\n> files that you also need to recover?\n>\n> --\n> Med vänliga hälsningar\n> Fredrik Gustafsson\n>\n> E-post: iveqy@iveqy.com\n> Tel. nr.: 0733 60 82 74\n>\n\nEvery file in the latest working tree is also a tracked file. The\nfiles are being added to the git repo, but not removed from it.\n\nIn other words, the biggest set of files is the latest working tree,\nand the smallest one is the first commit.\n\nDario\n"},{"id":"179140","messageId":"20111108150007.GA5261@kolya","threadId":"28886","inReplyTo":"CABLeVKFkSP=2-kwsN4N+oLrPnijkpvV8Ki=Si4dpYXdzc+8ibQ@mail.gmail.com","subject":"Re: Checkout first version of each file?","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2011-11-08T15:00:07Z","receivedAt":"2011-11-08T15:00:07Z","isPatch":false,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"On Tue, Nov 08, 2011 at 11:17:27AM -0300, Dario Rodriguez wrote:\n> On Tue, Nov 8, 2011 at 11:02 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:\n> > On Tue, Nov 08, 2011 at 10:58:05AM -0300, Dario Rodriguez wrote:\n> >> Hello,\n> >>\n> >> My \"issue\" comes with my usage of git at work. I work with lots of\n> >> applications, each of them part of each system. There are lots of\n> >> processes and lots of subsystems, so I never clone the entire repo\n> >> into GIT, since it could be painful and slow. Even if I do so,\n> >> everyone else is using ClearCase, and their changes cannot be included\n> >> into my git repo until they \"chickin\". Sometimes, I must update\n> >> sources from FTP because the changes are not up to date in\n> >> ClearCase...\n> >>\n> >> So, I clone every file that I will need to work into GIT, so i can\n> >> work with these files having a better control (With ClearCase it's a\n> >> foolish \"checkout>>lots of changes>>checkin\" flow). But sometimes I\n> >> don't know how many files I am going to change until I start coding\n> >> the requisites.\n> >>\n> >> In this cases, there is a situation that I don't know how to handle.\n> >> If I need to rollback every change made to every file I cannot just\n> >> checkout the initial commit, cause I've added files after that, and I\n> >> need their initial versions too.\n> >>\n> >> So, how can I checkout the first version of each file? (I know that\n> >> GIT tracks contents and not files, but the fact is that I need to keep\n> >> track on files, it's the real thing I work with)\n> >>\n> >> pd: Sorry about my Argentinian-English (if it sounds so)\n> >>\n> >> Thanks,\n> >> Dario\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> > Is all files present in your latest commit? Or can there be deleted\n> > files that you also need to recover?\n> >\n> > --\n> > Med vänliga hälsningar\n> > Fredrik Gustafsson\n> >\n> > E-post: iveqy@iveqy.com\n> > Tel. nr.: 0733 60 82 74\n> >\n> \n> Every file in the latest working tree is also a tracked file. The\n> files are being added to the git repo, but not removed from it.\n> \n> In other words, the biggest set of files is the latest working tree,\n> and the smallest one is the first commit.\n> \n> Dario\n\nI can't see a pure git way of doing this. However, you already seem to\nuse git in a very hackish-way. So here's a quick n' dirty solution (that\nis not very efficient).\n\n(not tested example code, that should be runned from the root-gitdir.):\n\n#!/bin/sh\ngit reset --hard HEAD\nfor f in `find`\ndo\n\tcommit=`git log $f | grep commit | tail -1`\n\tgit checkout $commit $f\ndone\n\n-- \nMed vänliga hälsningar\nFredrik Gustafsson\n\nE-post: iveqy@iveqy.com\nTel. nr.: 0733 60 82 74\n"},{"id":"179147","messageId":"CABLeVKEq3wtVxp8y1_Nv1tEA-0DEMk4QugkLDROY_XPAPc73yw@mail.gmail.com","threadId":"28886","inReplyTo":"20111108150007.GA5261@kolya","subject":"Re: Checkout first version of each file?","fromName":"Dario Rodriguez","fromEmail":"soft.d4rio@gmail.com","sentAt":"2011-11-08T17:20:24Z","receivedAt":"2011-11-08T17:20:24Z","isPatch":false,"sender":{"key":"soft.d4rio@gmail.com","avatar":"https://gravatar.com/avatar/9bca8035ad520a6fc0eb66e5126adbe45992c8388c05d1f7952bd4793eb82c22?d=mp&s=160"},"body":"On Tue, Nov 8, 2011 at 12:00 PM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:\n> On Tue, Nov 08, 2011 at 11:17:27AM -0300, Dario Rodriguez wrote:\n>> On Tue, Nov 8, 2011 at 11:02 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:\n>> > On Tue, Nov 08, 2011 at 10:58:05AM -0300, Dario Rodriguez wrote:\n>> >> Hello,\n>> >>\n>> >> My \"issue\" comes with my usage of git at work. I work with lots of\n>> >> applications, each of them part of each system. There are lots of\n>> >> processes and lots of subsystems, so I never clone the entire repo\n>> >> into GIT, since it could be painful and slow. Even if I do so,\n>> >> everyone else is using ClearCase, and their changes cannot be included\n>> >> into my git repo until they \"chickin\". Sometimes, I must update\n>> >> sources from FTP because the changes are not up to date in\n>> >> ClearCase...\n>> >>\n>> >> So, I clone every file that I will need to work into GIT, so i can\n>> >> work with these files having a better control (With ClearCase it's a\n>> >> foolish \"checkout>>lots of changes>>checkin\" flow). But sometimes I\n>> >> don't know how many files I am going to change until I start coding\n>> >> the requisites.\n>> >>\n>> >> In this cases, there is a situation that I don't know how to handle.\n>> >> If I need to rollback every change made to every file I cannot just\n>> >> checkout the initial commit, cause I've added files after that, and I\n>> >> need their initial versions too.\n>> >>\n>> >> So, how can I checkout the first version of each file? (I know that\n>> >> GIT tracks contents and not files, but the fact is that I need to keep\n>> >> track on files, it's the real thing I work with)\n>> >>\n>> >> pd: Sorry about my Argentinian-English (if it sounds so)\n>> >>\n>> >> Thanks,\n>> >> Dario\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>> > Is all files present in your latest commit? Or can there be deleted\n>> > files that you also need to recover?\n>> >\n>> > --\n>> > Med vänliga hälsningar\n>> > Fredrik Gustafsson\n>> >\n>> > E-post: iveqy@iveqy.com\n>> > Tel. nr.: 0733 60 82 74\n>> >\n>>\n>> Every file in the latest working tree is also a tracked file. The\n>> files are being added to the git repo, but not removed from it.\n>>\n>> In other words, the biggest set of files is the latest working tree,\n>> and the smallest one is the first commit.\n>>\n>> Dario\n>\n> I can't see a pure git way of doing this. However, you already seem to\n> use git in a very hackish-way. So here's a quick n' dirty solution (that\n> is not very efficient).\n>\n> (not tested example code, that should be runned from the root-gitdir.):\n>\n> #!/bin/sh\n> git reset --hard HEAD\n> for f in `find`\n> do\n>        commit=`git log $f | grep commit | tail -1`\n>        git checkout $commit $f\n> done\n>\n> --\n> Med vänliga hälsningar\n> Fredrik Gustafsson\n>\n> E-post: iveqy@iveqy.com\n> Tel. nr.: 0733 60 82 74\n>\n\nYes, it's similar to my approach, except that I used 'git ls-files'\nand 'git log --format=%H' to get the commit hash for each file\ninstead. Seems dirty, but reasonable if you think the git way.\n\nThank you,\nDario\n"},{"id":"179149","messageId":"7vzkg6y0dz.fsf@alter.siamese.dyndns.org","threadId":"28886","inReplyTo":"CABLeVKF5P_sWwNX+OR_FX4+SPCN+SovZ2QuMmGGvJ-EskK7=YQ@mail.gmail.com","subject":"Re: Checkout first version of each file?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-08T17:44:40Z","receivedAt":"2011-11-08T17:44:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dario Rodriguez <soft.d4rio@gmail.com> writes:\n\n> So, how can I checkout the first version of each file? (I know that\n> GIT tracks contents and not files, but the fact is that I need to keep\n> track on files, it's the real thing I work with)\n\nIn general \"the first version of a file\" is an undefined concept if your\nhistory has merges of parallel development, but in a narrow special case\nof linear history, you should be able to do something like this:\n\n    $ git log --format='# %h %s' --diff-filter=A --raw --abbrev=40\n\nwhich would give you something like\n\n    # 8d19b44 Git 1.7.7.2\n\n    :000000 100644 0000000... e6bbef2... A  Documentation/RelNotes/1.7.7.2.txt\n    # 0f77dea mingw: move poll out of sys-folder\n\n    :000000 100644 0000000... 708a6c9... A  compat/win32/poll.c\n    :000000 100644 0000000... b7aa59d... A  compat/win32/poll.h\n    # 8f41c07 read-cache.c: fix index memory allocation\n\n    :000000 100755 0000000... bca359d... A  t/t7511-status-index.sh\n    ...\n\nso that you know what blobs to check out to which path. E.g.\n\n    $ mkdir -p compat/win32; git cat-file blob 708a6c9... >compat/win32/poll.c\n"},{"id":"179153","messageId":"m239dypjkd.fsf@igel.home","threadId":"28886","inReplyTo":"20111108150007.GA5261@kolya","subject":"Re: Checkout first version of each file?","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2011-11-08T18:15:14Z","receivedAt":"2011-11-08T18:15:14Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Fredrik Gustafsson <iveqy@iveqy.com> writes:\n\n> #!/bin/sh\n> git reset --hard HEAD\n> for f in `find`\n            git ls-files\n> do\n> \tcommit=`git log $f | grep commit | tail -1`\n                git rev-list HEAD -- $f | tail -1\n> \tgit checkout $commit $f\n> done\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"179155","messageId":"CABLeVKG+2O4dQSOZ9NEiiLSse75skt0qH9zLXU3wkGzjSBz8YQ@mail.gmail.com","threadId":"28886","inReplyTo":"m239dypjkd.fsf@igel.home","subject":"Re: Checkout first version of each file?","fromName":"Dario Rodriguez","fromEmail":"soft.d4rio@gmail.com","sentAt":"2011-11-08T18:49:15Z","receivedAt":"2011-11-08T18:49:15Z","isPatch":false,"sender":{"key":"soft.d4rio@gmail.com","avatar":"https://gravatar.com/avatar/9bca8035ad520a6fc0eb66e5126adbe45992c8388c05d1f7952bd4793eb82c22?d=mp&s=160"},"body":"On Tue, Nov 8, 2011 at 3:15 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> Fredrik Gustafsson <iveqy@iveqy.com> writes:\n>\n>> #!/bin/sh\n>> git reset --hard HEAD\n>> for f in `find`\n>            git ls-files\n>> do\n>>       commit=`git log $f | grep commit | tail -1`\n>                git rev-list HEAD -- $f | tail -1\n>>       git checkout $commit $f\n>> done\n>\n> Andreas.\n>\n> --\n> Andreas Schwab, schwab@linux-m68k.org\n> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n> \"And now for something completely different.\"\n>\n\nThank you again guys,\n\nJunio, as part of the options applicable to diff-* commands, git-log\ncan take '--name-only' as argument. As the functionality of git log is\nto show commit logs (the user way) I wonder if we have some similar,\nparallel way to show a list of blobs. I mean, maybe the user (as in my\ncase) doesn't want the list of files, but the list of blobs, and the\nraw format is not a clean, friendly output.\nI can just: 'git log --oneline --name-only --diff-filter=A', but i\ncannot list blobs for each commit the same simple way.\n\nJust a suggestion, I think a little script fits better for me now.\n\nThank you,\nDario\n"}]}