Jason L. Shiffer bio photo

Jason L. Shiffer

I am what I am

Twitter Facebook Google+ LinkedIn Github Youtube

This is not a “new idea” but I can never find it when I need it. So if you too want to track some third party package that is not already in git (if it is then just fork it) then I suggest this method.


Initial import

$ mkdir <package>
$ cd <package>
$ tar -xzf <package>.tar.gz --strip-components 1
$ git add .
$ git commit -m "Import version X.Y.Z"
$ git tag vX.Y.Z
$ git branch vendor

Later Imports


$ git checkout vendor
$ rm -rf *
$ tar -xzf <package>.tar.gz --strip-components 1
$ git add .
$ git commit -a -m 'Import version X.Y.Z'
$ git tag vX.Y.Z
$ git checkout master
$ git rebase vendor

The tar option “–strip-components 1” extracts the files but not the top level directory (which is common in UNIX sources). So that I don’t have to move the files.

eg. a tar file eg. foo-0.1.3.tar.gz often has a layout like:

foo-0.1.3/
        file.c
        file.h
        ...

”–strip-components 1” will extract the files directly.