Do something like “svn export” with git

Zend framework recently moved to git and I'm starting to integrate it into our release scripts.
The previous command used svn export and the tag for the release I wanted.
It took a little while to figure out how to do this with git:

git clone --depth 1 --branch release-1.12.3 https://github.com/zendframework/zf1.git /where/do/you/want/it/zf1/1.12.3/
rm -f -r /var/www/vhosts/ZendFramework/1.12.3/.git

A few differences from svn:

  • git has the complete revision history in every checkout. By adding the –depth 1, we're only getting the history relevant to our selected 'branch' and greatly speeding up the checkout of this giant project.
  • git doesn't do tags like svn/cvs. A tag isn't a branch, its a human friendly name for a revision hash. The command is –branch but it doesn't have to be a branch. It can also be a tag or commit hash. You'll get a warning about head being disconnected, its not relevant in my case because I'm not making change to or managing this folder with .git after I get it checked out.
  • git doesn't have an 'export' method because it doesn't need it. All the git revisions are in the .git folder in the root of the project instead of spread all over kingdom come like cvs and svn. Just delete the .git folder and now the project is no longer under git revision control. ( Modern versions of svn have a single folder, just like git. Thanks Alan. )

This helped a lot and has other possible solutions.
http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export

 

derak

 

2 thoughts on “Do something like “svn export” with git

  1. As of Subversion 1.2, Subversion DOES NOT use .svn directories "all over kingdom". Gitters seem to over exaggerate just to diminish Subversion. It's a true shame.  Subversion as of 1.2 (it's now 1.8 and many versions later) only uses ONE ,,, yes ONE .svn directory just like .git.  There are many things I can say about GIT that are irritating (as a long time GIT/SVN administrator), but choose to not bash a tool for its PAST short comings.

    Subversion for the record exports all the code via ONE command line argument: svn export <url> DONE! GIT requires two commands to accomplish the same thing (see above).  I'm just statnig the facts – live with it!

     

     

    1. Good to know. My experience with SVN was very brief.
      We jumped from CVS to GIT so I roughly equate SVN to CVS.
      Glad to hear that’s not really the case anymore.
      That helps me understand why this stalwart of development hasn’t been completely replaced by git and mercurial yet.

Leave a Reply

Your email address will not be published. Required fields are marked *