git-hacks

git-hacks Git Source Tree

Root/git-export

1#! /bin/sh -
2#
3# Make a clean export (as done by svn-export) of
4# HEAD and put it in a compressed tarball (.tar.xz).
5# The tarball will *not* include any file outside
6# of the git repository.
7#
8# This is useful when you need to make a portable
9# snapshot of your project and you are not using
10# autotools or other build systems.
11#
12#
13# Installation
14# ============
15#
16# Put the script somewhere in your path.
17#
18#
19# Usage
20# =====
21#
22# git export [TARNAME]
23#
24# The tarball is always generated in the current
25# working directory.
26#
27# If TARNAME is not specified, the tarball will
28# be named according to the basename of the git
29# root. For example, if you do a `git export' in
30# /home/user/myproject, the tarball will be
31# myproject.tar.xz.
32#
33# TARNAME will be also used as prefix to the
34# files added into the archive.
35
36basedir="$(git rev-parse --show-toplevel)"
37
38tarname="$1"
39[ -z "$tarname" ] && tarname="$(basename $basedir)"
40
41git archive --format=tar --remote="$basedir" --prefix="$tarname/" HEAD | xz - > $tarname.tar.xz

Archive Download this file

Branches