From: Paul Gideon Dann <pdgiddie@googlemail.com>
To: git@vger.kernel.org
Subject: git-attic
Date: Tue, 29 Jul 2008 12:57:38 +0100 [thread overview]
Message-ID: <488F05B2.6060209@gmail.com> (raw)
Hello all,
I looked around everywhere for a script that could make it easy for me
to store stale branches in refs/attic for possible later retrieval. I
don't like such branches lying around in refs/heads and used to tag them
to clear them out of the way, but then that makes "git push origin
--tags" unusable, since I don't want to push my stale branches out...
Anyway, I wrote my own little script in the end and thought it might be
useful to others.
Please Cc pdgiddie@gmail.com in replies,
Paul Gideon Dann
Usage: git-attic
git-attic store <ref> [<commit>]
git-attic remove <ref>
#!/bin/bash
###
# Original Author: Paul Gideon Dann <pdgiddie@gmail.com>
###
showUsage() {
echo "Usage: git-attic"
echo " git-attic store <ref> [<commit>]"
echo " git-attic remove <ref>"
}
case $1 in
"store")
if [[ ! $2 ]]; then
showUsage
exit 1
fi
if [[ $3 ]]; then
OBJECT_SHA1=`git-rev-parse --revs-only $3`
if [[ ! $OBJECT_SHA1 ]]; then
echo "$3 is not a recognisable commit object."
exit 1
fi
else
OBJECT_SHA1=`git show-ref -h HEAD | awk '{print $1}'`
fi
git update-ref refs/attic/$2 $OBJECT_SHA1
echo "$2 stored in attic."
;;
"remove")
if [[ ! $2 ]]; then
showUsage
exit 1
fi
OBJECT_SHA1=`git show-ref attic/$2 | awk '{print $1}'`
if [[ ! $OBJECT_SHA1 ]]; then
echo "$2 does not exist in the attic!"
exit 1
fi
git update-ref -d refs/attic/$2 $OBJECT_SHA1
echo "$2 removed from attic."
;;
*)
if [[ $1 ]]; then
showUsage
else
# display contents of attic
git for-each-ref --format="%(refname)" refs/attic | awk -F /
'{print $3}'
fi
;;
esac
next reply other threads:[~2008-07-29 11:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-29 11:57 Paul Gideon Dann [this message]
2008-07-29 16:51 ` git-attic Eric Raible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=488F05B2.6060209@gmail.com \
--to=pdgiddie@googlemail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).