Thread: Working with git repo tagged versions

Working with git repo tagged versions

From
Robert Treat
Date:
Howdy folks,

Occasionally I need to grab an older release from git based on a tag
rather than a branch, eg the REL8_3_10 tag vs the REL8_3_STABLE
branch. I used to know how to do this in CVS, but I find I tend to
revert to grabbing tarballs now that we're on git. So, I'm wondering
if anyone knows a way to do this directly from git clone (or similar),
and ideally as a shallow clone (ie. I just need a copy of the code at
that tag, rather than needing the repo for development purposes). If
anyone knew a way to do this down to a specific commit, that would
also be interesting to know. Thanks in advance.


Robert Treat
conjecture: xzilla.net
consulting: omniti.com


Re: Working with git repo tagged versions

From
Bruce Momjian
Date:
Robert Treat wrote:
> Howdy folks,
> 
> Occasionally I need to grab an older release from git based on a tag
> rather than a branch, eg the REL8_3_10 tag vs the REL8_3_STABLE
> branch. I used to know how to do this in CVS, but I find I tend to
> revert to grabbing tarballs now that we're on git. So, I'm wondering
> if anyone knows a way to do this directly from git clone (or similar),
> and ideally as a shallow clone (ie. I just need a copy of the code at
> that tag, rather than needing the repo for development purposes). If
> anyone knew a way to do this down to a specific commit, that would
> also be interesting to know. Thanks in advance.

I just did this:
$ git-new-workdir postgresql/.git/ tmpChecking out files: 100% (3903/3903), done.$ cd tmp$ git checkout REL8_3_10

That does use a shadow clone.  Basically, git checkout assumes a tag,
unless you -b for a branch.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: Working with git repo tagged versions

From
Alvaro Herrera
Date:
Excerpts from Robert Treat's message of vie nov 11 17:18:43 -0300 2011:
> Howdy folks,
> 
> Occasionally I need to grab an older release from git based on a tag
> rather than a branch, eg the REL8_3_10 tag vs the REL8_3_STABLE
> branch. I used to know how to do this in CVS, but I find I tend to
> revert to grabbing tarballs now that we're on git. So, I'm wondering
> if anyone knows a way to do this directly from git clone (or similar),
> and ideally as a shallow clone (ie. I just need a copy of the code at
> that tag, rather than needing the repo for development purposes). If
> anyone knew a way to do this down to a specific commit, that would
> also be interesting to know. Thanks in advance.

Maybe the github clone can be helpful -- for example try an URL such as

https://github.com/postgres/postgres/tarball/cf22e851b6ae8737f3e767dffcadf1722fbb36a7

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Working with git repo tagged versions

From
Andrew Dunstan
Date:

On 11/11/2011 03:53 PM, Bruce Momjian wrote:
> Robert Treat wrote:
>> Howdy folks,
>>
>> Occasionally I need to grab an older release from git based on a tag
>> rather than a branch, eg the REL8_3_10 tag vs the REL8_3_STABLE
>> branch. I used to know how to do this in CVS, but I find I tend to
>> revert to grabbing tarballs now that we're on git. So, I'm wondering
>> if anyone knows a way to do this directly from git clone (or similar),
>> and ideally as a shallow clone (ie. I just need a copy of the code at
>> that tag, rather than needing the repo for development purposes). If
>> anyone knew a way to do this down to a specific commit, that would
>> also be interesting to know. Thanks in advance.
> I just did this:
>
>     $ git-new-workdir postgresql/.git/ tmp
>     Checking out files: 100% (3903/3903), done.
>     $ cd tmp
>     $ git checkout REL8_3_10
>
> That does use a shadow clone.  Basically, git checkout assumes a tag,
> unless you -b for a branch.
>

or just something like:
   mkdir ../pg8.3.10 &&  git archive --format=tar REL8_3_10 | tar -C   ../pg8.3.10 -xf -


since he says he doesn't need the git infrastructure.

cheers

andrew



Re: Working with git repo tagged versions

From
Tom Lane
Date:
Robert Treat <rob@xzilla.net> writes:
> Occasionally I need to grab an older release from git based on a tag
> rather than a branch, eg the REL8_3_10 tag vs the REL8_3_STABLE
> branch. I used to know how to do this in CVS, but I find I tend to
> revert to grabbing tarballs now that we're on git. So, I'm wondering
> if anyone knows a way to do this directly from git clone (or similar),
> and ideally as a shallow clone (ie. I just need a copy of the code at
> that tag, rather than needing the repo for development purposes). If
> anyone knew a way to do this down to a specific commit, that would
> also be interesting to know. Thanks in advance.

FWIW, this is what we use in the script that makes release tarballs:
 export GIT_DIR=[ where your git clone is ] git archive ${COMMITHASH} | tar xf - -C pgsql
        regards, tom lane


Re: Working with git repo tagged versions

From
Peter Eisentraut
Date:
On fre, 2011-11-11 at 15:53 -0500, Bruce Momjian wrote:
> Basically, git checkout assumes a tag, unless you -b for a branch. 

No, git checkout assumes a branch, and if it doesn't find a branch, it
looks for a commit by the given name, and a tag is one way of naming a
commit.  The -b option creates a new branch.