git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to git-archive ignore some files?

From
David Bryson <david@statichacks.org>
Date
May 8, 2008, 17:04 UTC
Message-ID
<20080508170442.GK9562@eratosthenes.sbcglobal.net>
In-Reply-To
<1210097731.5238.3.camel@omicron.ep.petrobras.com.br>
Hi Victor,
On Tue, May 06, 2008 at 03:15:31PM -0300 or thereabouts, Victor Bogado da Silva Lins wrote:
Show 6 quoted lines
> I want to use git-archive to create source packages, but my git
> repository has a .gitignore that I don't want to be pushed into the
> archive. So is it possible to keep the .gitignore file in the repository
> and create an archive(*) without it? 
> 
> *) using git-archive, off course. 

Others already discussed the --delete method with tar, and I do something similar except slightly more flexible. I have for example, a git repo that checks out directories from CVS, and of course I don't want these CVS directories in my 'release'. So put a executable '.release' file in each repo that tells my release script how to fix up the tarball to be production ready.

Here is my release script, modeled after some lines Linus put in the git documentation. It is meant to be run, reviewed for mistakes, and then have the commands run via cut-paste.

#!/bin/bash stable="$1" last="$2" new="$3" chip="$4" rel=`pwd | cut -d'/' -f6 | sed -e 's/\.git//'`

if [ -z $chip ]; then
	reldir=$rel
else
	reldir=$rel-$chip
fi

reldir="$reldir-$new" tarfile="$reldir.tar"

if [ -d $reldir ]; then
	echo "release directory $reldir already exists, please remove" 1>&2
	exit 1
fi
if [ -f "../$reldir.tar" ]; then
	echo "Release file ../$reldir.tar already exists, please remove" 1>&2
	exit 1
fi
if [ -f "../$reldir.tar.gz" ]; then
	echo "Release file ../$reldir.tar.gz already exists, please remove" 1>&2
	exit 1
fi
echo "#git tag v$new"
echo "Tagging new release v$new" 1>&2
echo "git archive --prefix=$reldir/ v$new > ../$tarfile"
echo "mkdir $reldir"
#echo "git diff v$stable v$new | gzip -9 > ../patch-$new.gz"
echo "git log --no-merges v$new ^v$last > $reldir/ChangeLog-$new"
echo "git shortlog --no-merges v$new ^v$last > $reldir/ShortLog"
echo "git diff --stat --summary -M v$last v$new > $reldir/diffstat-$new"
echo "tar -rf ../$tarfile $reldir/*"
./.release $reldir ../$tarfile
if [ $? != 0 ]; then
	echo ".release script failed! removing generated files" 1>&2
	echo "rm -rf $reldir ../$tarfile"
	exit 1
fi
echo "gzip -9 < ../$tarfile > ../$tarfile.gz"
echo "rm -rf $reldir ../$tarfile"
echo "New release at ../$tarfile.gz" 1>&2
And an example .release file

#!/bin/bash dirlist="make foo_include scripts" excludes="--exclude CVS --exclude '*.o' --exclude '*.swp' --exclude '*.d' --exclude '*.a'" reldir=$1 tarfile=$2 #echo "make doc && make -C doc/latex pdf" echo "cp -a $dirlist $reldir" echo "cp Makefile.release $reldir/Makefile" echo "tar $excludes -rf $tarfile $reldir/*"

# write over the makefile echo "cp Makefile.release $reldir/Makefile" echo "tar -u -f $tarfile $reldir/Makefile" echo "tar --delete --file=$tarfile $reldir/Makefile.release"

# delete the doxygen file echo "cp Doxyfile $reldir" echo "tar --delete --file=$tarfile $reldir/Doxyfile"

# remove traces of the release file echo "tar --delete --file=$tarfile $reldir/.release"

Previous: René ScharfeNext: Johannes Schindelin
Message 9 of 10 in “how to git-archive ignore some files?”
  1. Victor Bogado da Silva LinsMay 6, 2008
  2. Sean EstabrooksMay 6, 2008
  3. René ScharfeMay 6, 2008
  4. Junio C HamanoMay 6, 2008
  5. René ScharfeMay 11, 2008
  6. Junio C HamanoMay 11, 2008
  7. Jakub NarebskiMay 12, 2008
  8. René ScharfeJun 8, 2008
  9. David BrysonMay 8, 2008
  10. Johannes SchindelinMay 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.