git-hacks

git-hacks Commit Details

Date:2012-10-26 16:58:44 (7 years 1 month ago)
Author:Nicola Fontana
Branch:master
Commit:deb05091eb243a5bda5bbc2e9425ce804c42a5eb
Parents: a9b924a775655893a6924753e86e5d6a87b0e736
Message:git-export: general enhancements

Changes:
Mgit-export (1 diff)

File differences

git-export
11
22
3
4
5
3
4
5
6
67
7
8
8
9
10
911
10
11
1212
13
14
13
14
1515
16
17
18
19
20
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2135
22
36
2337
24
25
26
27
28
29
38
39
3040
31
41
#! /bin/sh -
#
# Make a clean export (as done by svn-export) of HEAD
# from the given REPOSITORY and store the result to PATH.
# If PATH is not specified, the current path will be used.
# Make a clean export (as done by svn-export) of
# HEAD and put it in a compressed tarball (.tar.xz).
# The tarball will *not* include any file outside
# of the git repository.
#
# Usage:
# git export REPOSITORY [PATH]"
# This is useful when you need to make a portable
# snapshot of your project and you are not using
# autotools or other build systems.
#
# To export the working directory of the current repository
# into wd, the following approaches are equivalents:
#
# git export . wd
# cd wd
# Installation
# ============
#
# mkdir wd
# cd wd
# git export ..
[ -z "$1" ] && exit 1
# Put the script somewhere in your path.
#
#
# Usage
# =====
#
# git export [TARNAME]
#
# The tarball is always generated in the current
# working directory.
#
# If TARNAME is not specified, the tarball will
# be named according to the basename of the git
# root. For example, if you do a `git export' in
# /home/user/myproject, the tarball will be
# myproject.tar.xz.
#
# TARNAME will be also used as prefix to the
# files added into the archive.
options="--remote=$1"
basedir="$(git rev-parse --show-toplevel)"
if [ -n "$2" ]; then
options="$options --prefix=$2"
# Append the trailing slash, required by git archive
# but always forgotten (at least by me)
[ "x${options: -1}" != "x/" ] && options="$options/"
fi
tarname="$1"
[ -z "$tarname" ] && tarname="$(basename $basedir)"
git archive --format=tar $options master | tar -xf -
git archive --format=tar --remote="$basedir" --prefix="$tarname/" HEAD | xz - > $tarname.tar.xz

Archive Download the corresponding diff file

Branches