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

Re: Checkout first version of each file?

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 8, 2011, 17:44 UTC
Message-ID
<7vzkg6y0dz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CABLeVKF5P_sWwNX+OR_FX4+SPCN+SovZ2QuMmGGvJ-EskK7=YQ@mail.gmail.com>
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
Previous: Dario Rodriguez
Message 8 of 8 in “Checkout first version of each file?”
  1. Dario RodriguezNov 8, 2011
  2. Fredrik GustafssonNov 8, 2011
  3. Dario RodriguezNov 8, 2011
  4. Fredrik GustafssonNov 8, 2011
  5. Dario RodriguezNov 8, 2011
  6. Andreas SchwabNov 8, 2011
  7. Dario RodriguezNov 8, 2011
  8. Junio C HamanoNov 8, 2011

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.