git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Checkout first version of each file?
@ 2011-11-08 13:58 Dario Rodriguez
  2011-11-08 14:02 ` Fredrik Gustafsson
  2011-11-08 17:44 ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Dario Rodriguez @ 2011-11-08 13:58 UTC (permalink / raw)
  To: Git Mailing List

Hello,

My "issue" comes with my usage of git at work. I work with lots of
applications, each of them part of each system. There are lots of
processes and lots of subsystems, so I never clone the entire repo
into GIT, since it could be painful and slow. Even if I do so,
everyone else is using ClearCase, and their changes cannot be included
into my git repo until they "chickin". Sometimes, I must update
sources from FTP because the changes are not up to date in
ClearCase...

So, I clone every file that I will need to work into GIT, so i can
work with these files having a better control (With ClearCase it's a
foolish "checkout>>lots of changes>>checkin" flow). But sometimes I
don't know how many files I am going to change until I start coding
the requisites.

In this cases, there is a situation that I don't know how to handle.
If I need to rollback every change made to every file I cannot just
checkout the initial commit, cause I've added files after that, and I
need their initial versions too.

So, how can I checkout the first version of each file? (I know that
GIT tracks contents and not files, but the fact is that I need to keep
track on files, it's the real thing I work with)

pd: Sorry about my Argentinian-English (if it sounds so)

Thanks,
Dario

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Checkout first version of each file?
  2011-11-08 13:58 Checkout first version of each file? Dario Rodriguez
@ 2011-11-08 14:02 ` Fredrik Gustafsson
  2011-11-08 14:17   ` Dario Rodriguez
  2011-11-08 17:44 ` Junio C Hamano
  1 sibling, 1 reply; 8+ messages in thread
From: Fredrik Gustafsson @ 2011-11-08 14:02 UTC (permalink / raw)
  To: Dario Rodriguez; +Cc: Git Mailing List

On Tue, Nov 08, 2011 at 10:58:05AM -0300, Dario Rodriguez wrote:
> Hello,
> 
> My "issue" comes with my usage of git at work. I work with lots of
> applications, each of them part of each system. There are lots of
> processes and lots of subsystems, so I never clone the entire repo
> into GIT, since it could be painful and slow. Even if I do so,
> everyone else is using ClearCase, and their changes cannot be included
> into my git repo until they "chickin". Sometimes, I must update
> sources from FTP because the changes are not up to date in
> ClearCase...
> 
> So, I clone every file that I will need to work into GIT, so i can
> work with these files having a better control (With ClearCase it's a
> foolish "checkout>>lots of changes>>checkin" flow). But sometimes I
> don't know how many files I am going to change until I start coding
> the requisites.
> 
> In this cases, there is a situation that I don't know how to handle.
> If I need to rollback every change made to every file I cannot just
> checkout the initial commit, cause I've added files after that, and I
> need their initial versions too.
> 
> So, how can I checkout the first version of each file? (I know that
> GIT tracks contents and not files, but the fact is that I need to keep
> track on files, it's the real thing I work with)
> 
> pd: Sorry about my Argentinian-English (if it sounds so)
> 
> Thanks,
> Dario
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Is all files present in your latest commit? Or can there be deleted
files that you also need to recover?

-- 
Med vänliga hälsningar
Fredrik Gustafsson

E-post: iveqy@iveqy.com
Tel. nr.: 0733 60 82 74

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Checkout first version of each file?
  2011-11-08 14:02 ` Fredrik Gustafsson
@ 2011-11-08 14:17   ` Dario Rodriguez
  2011-11-08 15:00     ` Fredrik Gustafsson
  0 siblings, 1 reply; 8+ messages in thread
From: Dario Rodriguez @ 2011-11-08 14:17 UTC (permalink / raw)
  To: Fredrik Gustafsson; +Cc: Git Mailing List

On Tue, Nov 8, 2011 at 11:02 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:
> On Tue, Nov 08, 2011 at 10:58:05AM -0300, Dario Rodriguez wrote:
>> Hello,
>>
>> My "issue" comes with my usage of git at work. I work with lots of
>> applications, each of them part of each system. There are lots of
>> processes and lots of subsystems, so I never clone the entire repo
>> into GIT, since it could be painful and slow. Even if I do so,
>> everyone else is using ClearCase, and their changes cannot be included
>> into my git repo until they "chickin". Sometimes, I must update
>> sources from FTP because the changes are not up to date in
>> ClearCase...
>>
>> So, I clone every file that I will need to work into GIT, so i can
>> work with these files having a better control (With ClearCase it's a
>> foolish "checkout>>lots of changes>>checkin" flow). But sometimes I
>> don't know how many files I am going to change until I start coding
>> the requisites.
>>
>> In this cases, there is a situation that I don't know how to handle.
>> If I need to rollback every change made to every file I cannot just
>> checkout the initial commit, cause I've added files after that, and I
>> need their initial versions too.
>>
>> So, how can I checkout the first version of each file? (I know that
>> GIT tracks contents and not files, but the fact is that I need to keep
>> track on files, it's the real thing I work with)
>>
>> pd: Sorry about my Argentinian-English (if it sounds so)
>>
>> Thanks,
>> Dario
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> Is all files present in your latest commit? Or can there be deleted
> files that you also need to recover?
>
> --
> Med vänliga hälsningar
> Fredrik Gustafsson
>
> E-post: iveqy@iveqy.com
> Tel. nr.: 0733 60 82 74
>

Every file in the latest working tree is also a tracked file. The
files are being added to the git repo, but not removed from it.

In other words, the biggest set of files is the latest working tree,
and the smallest one is the first commit.

Dario

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Checkout first version of each file?
  2011-11-08 14:17   ` Dario Rodriguez
@ 2011-11-08 15:00     ` Fredrik Gustafsson
  2011-11-08 17:20       ` Dario Rodriguez
  2011-11-08 18:15       ` Andreas Schwab
  0 siblings, 2 replies; 8+ messages in thread
From: Fredrik Gustafsson @ 2011-11-08 15:00 UTC (permalink / raw)
  To: Dario Rodriguez; +Cc: Fredrik Gustafsson, Git Mailing List

On Tue, Nov 08, 2011 at 11:17:27AM -0300, Dario Rodriguez wrote:
> On Tue, Nov 8, 2011 at 11:02 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:
> > On Tue, Nov 08, 2011 at 10:58:05AM -0300, Dario Rodriguez wrote:
> >> Hello,
> >>
> >> My "issue" comes with my usage of git at work. I work with lots of
> >> applications, each of them part of each system. There are lots of
> >> processes and lots of subsystems, so I never clone the entire repo
> >> into GIT, since it could be painful and slow. Even if I do so,
> >> everyone else is using ClearCase, and their changes cannot be included
> >> into my git repo until they "chickin". Sometimes, I must update
> >> sources from FTP because the changes are not up to date in
> >> ClearCase...
> >>
> >> So, I clone every file that I will need to work into GIT, so i can
> >> work with these files having a better control (With ClearCase it's a
> >> foolish "checkout>>lots of changes>>checkin" flow). But sometimes I
> >> don't know how many files I am going to change until I start coding
> >> the requisites.
> >>
> >> In this cases, there is a situation that I don't know how to handle.
> >> If I need to rollback every change made to every file I cannot just
> >> checkout the initial commit, cause I've added files after that, and I
> >> need their initial versions too.
> >>
> >> So, how can I checkout the first version of each file? (I know that
> >> GIT tracks contents and not files, but the fact is that I need to keep
> >> track on files, it's the real thing I work with)
> >>
> >> pd: Sorry about my Argentinian-English (if it sounds so)
> >>
> >> Thanks,
> >> Dario
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe git" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> > Is all files present in your latest commit? Or can there be deleted
> > files that you also need to recover?
> >
> > --
> > Med vänliga hälsningar
> > Fredrik Gustafsson
> >
> > E-post: iveqy@iveqy.com
> > Tel. nr.: 0733 60 82 74
> >
> 
> Every file in the latest working tree is also a tracked file. The
> files are being added to the git repo, but not removed from it.
> 
> In other words, the biggest set of files is the latest working tree,
> and the smallest one is the first commit.
> 
> Dario

I can't see a pure git way of doing this. However, you already seem to
use git in a very hackish-way. So here's a quick n' dirty solution (that
is not very efficient).

(not tested example code, that should be runned from the root-gitdir.):

#!/bin/sh
git reset --hard HEAD
for f in `find`
do
	commit=`git log $f | grep commit | tail -1`
	git checkout $commit $f
done

-- 
Med vänliga hälsningar
Fredrik Gustafsson

E-post: iveqy@iveqy.com
Tel. nr.: 0733 60 82 74

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Checkout first version of each file?
  2011-11-08 15:00     ` Fredrik Gustafsson
@ 2011-11-08 17:20       ` Dario Rodriguez
  2011-11-08 18:15       ` Andreas Schwab
  1 sibling, 0 replies; 8+ messages in thread
From: Dario Rodriguez @ 2011-11-08 17:20 UTC (permalink / raw)
  To: Fredrik Gustafsson; +Cc: Git Mailing List

On Tue, Nov 8, 2011 at 12:00 PM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:
> On Tue, Nov 08, 2011 at 11:17:27AM -0300, Dario Rodriguez wrote:
>> On Tue, Nov 8, 2011 at 11:02 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:
>> > On Tue, Nov 08, 2011 at 10:58:05AM -0300, Dario Rodriguez wrote:
>> >> Hello,
>> >>
>> >> My "issue" comes with my usage of git at work. I work with lots of
>> >> applications, each of them part of each system. There are lots of
>> >> processes and lots of subsystems, so I never clone the entire repo
>> >> into GIT, since it could be painful and slow. Even if I do so,
>> >> everyone else is using ClearCase, and their changes cannot be included
>> >> into my git repo until they "chickin". Sometimes, I must update
>> >> sources from FTP because the changes are not up to date in
>> >> ClearCase...
>> >>
>> >> So, I clone every file that I will need to work into GIT, so i can
>> >> work with these files having a better control (With ClearCase it's a
>> >> foolish "checkout>>lots of changes>>checkin" flow). But sometimes I
>> >> don't know how many files I am going to change until I start coding
>> >> the requisites.
>> >>
>> >> In this cases, there is a situation that I don't know how to handle.
>> >> If I need to rollback every change made to every file I cannot just
>> >> checkout the initial commit, cause I've added files after that, and I
>> >> need their initial versions too.
>> >>
>> >> So, how can I checkout the first version of each file? (I know that
>> >> GIT tracks contents and not files, but the fact is that I need to keep
>> >> track on files, it's the real thing I work with)
>> >>
>> >> pd: Sorry about my Argentinian-English (if it sounds so)
>> >>
>> >> Thanks,
>> >> Dario
>> >> --
>> >> To unsubscribe from this list: send the line "unsubscribe git" in
>> >> the body of a message to majordomo@vger.kernel.org
>> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> >
>> > Is all files present in your latest commit? Or can there be deleted
>> > files that you also need to recover?
>> >
>> > --
>> > Med vänliga hälsningar
>> > Fredrik Gustafsson
>> >
>> > E-post: iveqy@iveqy.com
>> > Tel. nr.: 0733 60 82 74
>> >
>>
>> Every file in the latest working tree is also a tracked file. The
>> files are being added to the git repo, but not removed from it.
>>
>> In other words, the biggest set of files is the latest working tree,
>> and the smallest one is the first commit.
>>
>> Dario
>
> I can't see a pure git way of doing this. However, you already seem to
> use git in a very hackish-way. So here's a quick n' dirty solution (that
> is not very efficient).
>
> (not tested example code, that should be runned from the root-gitdir.):
>
> #!/bin/sh
> git reset --hard HEAD
> for f in `find`
> do
>        commit=`git log $f | grep commit | tail -1`
>        git checkout $commit $f
> done
>
> --
> Med vänliga hälsningar
> Fredrik Gustafsson
>
> E-post: iveqy@iveqy.com
> Tel. nr.: 0733 60 82 74
>

Yes, it's similar to my approach, except that I used 'git ls-files'
and 'git log --format=%H' to get the commit hash for each file
instead. Seems dirty, but reasonable if you think the git way.

Thank you,
Dario

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Checkout first version of each file?
  2011-11-08 13:58 Checkout first version of each file? Dario Rodriguez
  2011-11-08 14:02 ` Fredrik Gustafsson
@ 2011-11-08 17:44 ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2011-11-08 17:44 UTC (permalink / raw)
  To: Dario Rodriguez; +Cc: Git Mailing List

Dario Rodriguez <soft.d4rio@gmail.com> writes:

> So, how can I checkout the first version of each file? (I know that
> GIT tracks contents and not files, but the fact is that I need to keep
> track on files, it's the real thing I work with)

In general "the first version of a file" is an undefined concept if your
history has merges of parallel development, but in a narrow special case
of linear history, you should be able to do something like this:

    $ git log --format='# %h %s' --diff-filter=A --raw --abbrev=40

which would give you something like

    # 8d19b44 Git 1.7.7.2

    :000000 100644 0000000... e6bbef2... A  Documentation/RelNotes/1.7.7.2.txt
    # 0f77dea mingw: move poll out of sys-folder

    :000000 100644 0000000... 708a6c9... A  compat/win32/poll.c
    :000000 100644 0000000... b7aa59d... A  compat/win32/poll.h
    # 8f41c07 read-cache.c: fix index memory allocation

    :000000 100755 0000000... bca359d... A  t/t7511-status-index.sh
    ...

so that you know what blobs to check out to which path. E.g.

    $ mkdir -p compat/win32; git cat-file blob 708a6c9... >compat/win32/poll.c

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Checkout first version of each file?
  2011-11-08 15:00     ` Fredrik Gustafsson
  2011-11-08 17:20       ` Dario Rodriguez
@ 2011-11-08 18:15       ` Andreas Schwab
  2011-11-08 18:49         ` Dario Rodriguez
  1 sibling, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2011-11-08 18:15 UTC (permalink / raw)
  To: Fredrik Gustafsson; +Cc: Dario Rodriguez, Git Mailing List

Fredrik Gustafsson <iveqy@iveqy.com> writes:

> #!/bin/sh
> git reset --hard HEAD
> for f in `find`
            git ls-files
> do
> 	commit=`git log $f | grep commit | tail -1`
                git rev-list HEAD -- $f | tail -1
> 	git checkout $commit $f
> done

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Checkout first version of each file?
  2011-11-08 18:15       ` Andreas Schwab
@ 2011-11-08 18:49         ` Dario Rodriguez
  0 siblings, 0 replies; 8+ messages in thread
From: Dario Rodriguez @ 2011-11-08 18:49 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Fredrik Gustafsson, Git Mailing List

On Tue, Nov 8, 2011 at 3:15 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Fredrik Gustafsson <iveqy@iveqy.com> writes:
>
>> #!/bin/sh
>> git reset --hard HEAD
>> for f in `find`
>            git ls-files
>> do
>>       commit=`git log $f | grep commit | tail -1`
>                git rev-list HEAD -- $f | tail -1
>>       git checkout $commit $f
>> done
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>

Thank you again guys,

Junio, as part of the options applicable to diff-* commands, git-log
can take '--name-only' as argument. As the functionality of git log is
to show commit logs (the user way) I wonder if we have some similar,
parallel way to show a list of blobs. I mean, maybe the user (as in my
case) doesn't want the list of files, but the list of blobs, and the
raw format is not a clean, friendly output.
I can just: 'git log --oneline --name-only --diff-filter=A', but i
cannot list blobs for each commit the same simple way.

Just a suggestion, I think a little script fits better for me now.

Thank you,
Dario

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-11-08 18:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 13:58 Checkout first version of each file? Dario Rodriguez
2011-11-08 14:02 ` Fredrik Gustafsson
2011-11-08 14:17   ` Dario Rodriguez
2011-11-08 15:00     ` Fredrik Gustafsson
2011-11-08 17:20       ` Dario Rodriguez
2011-11-08 18:15       ` Andreas Schwab
2011-11-08 18:49         ` Dario Rodriguez
2011-11-08 17:44 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).