Skip to content

Commit f4a7d1e

Browse files
committed
Added git-export command to improve archiving of git repositories.
1 parent db8ff55 commit f4a7d1e

File tree

3 files changed

+62
-20
lines changed

3 files changed

+62
-20
lines changed

README.html

+18-10
Original file line numberDiff line numberDiff line change
@@ -340,16 +340,6 @@
340340
</ul>
341341
<p class="last">Designed to finish up a local topic/feature branch</p>
342342
</dd>
343-
<dt><strong>git-move-commits</strong></dt>
344-
<dd><p class="first"><em>Usage:</em> <tt class="docutils literal">git <span class="pre">move-commits</span> <span class="pre">&lt;num-commits&gt;</span> <span class="pre">&lt;correct-branch&gt;</span></tt></p>
345-
<ul class="simple">
346-
<li>Moves the last <tt class="docutils literal"><span class="pre">num-commits</span></tt> commits to <tt class="docutils literal"><span class="pre">correct-branch</span></tt></li>
347-
<li>If <tt class="docutils literal"><span class="pre">correct-branch</span></tt> doesn't exist, the script creates it</li>
348-
<li>if <tt class="docutils literal"><span class="pre">correct-branch</span></tt> does exist, the script merges the commits</li>
349-
</ul>
350-
<p class="last">If you commit to the wrong branch (especially <tt class="docutils literal">master</tt>), this script
351-
will fix that for you.</p>
352-
</dd>
353343
<dt><strong>git-pull-branch</strong></dt>
354344
<dd><p class="first"><em>Usage:</em> <tt class="docutils literal">git <span class="pre">pull-branch</span> &lt;branchname&gt;</tt></p>
355345
<ul class="simple">
@@ -366,6 +356,24 @@
366356
<p class="last">A simple shortcut to get a local branch on a server without having to
367357
execute three different commands</p>
368358
</dd>
359+
<dt><strong>git-move-commits</strong></dt>
360+
<dd><p class="first"><em>Usage:</em> <tt class="docutils literal">git <span class="pre">move-commits</span> <span class="pre">&lt;num-commits&gt;</span> <span class="pre">&lt;correct-branch&gt;</span></tt></p>
361+
<ul class="simple">
362+
<li>Moves the last <tt class="docutils literal"><span class="pre">num-commits</span></tt> commits to <tt class="docutils literal"><span class="pre">correct-branch</span></tt></li>
363+
<li>If <tt class="docutils literal"><span class="pre">correct-branch</span></tt> doesn't exist, the script creates it</li>
364+
<li>if <tt class="docutils literal"><span class="pre">correct-branch</span></tt> does exist, the script merges the commits</li>
365+
</ul>
366+
<p class="last">If you commit to the wrong branch (especially <tt class="docutils literal">master</tt>), this script
367+
will fix that for you.</p>
368+
</dd>
369+
<dt><strong>git-branch-from</strong></dt>
370+
<dd><p class="first"><em>Usage:</em> <tt class="docutils literal">git <span class="pre">branch-from</span> <span class="pre">&lt;commit-reference&gt;</span> <span class="pre">&lt;new-branch-name&gt;</span></tt></p>
371+
<p class="last">If you made several commits to a branch (especially <tt class="docutils literal">master</tt>), and in retrospect, you really should have been doing that on a new branch, this will create a new branch from the <tt class="docutils literal"><span class="pre">commit-reference</span></tt> and reset current branch to the <tt class="docutils literal"><span class="pre">commit-reference</span></tt>.</p>
372+
</dd>
373+
<dt><strong>git-export</strong></dt>
374+
<dd><p class="first"><em>Usage:</em> <tt class="docutils literal">git export <span class="pre">&lt;commit-reference&gt;</span> [&lt;filename&gt;]</tt></p>
375+
<p class="last">Exports a tar-gzipped archive of the <tt class="docutils literal"><span class="pre">commit-reference</span></tt>. If <tt class="docutils literal">&lt;filename&gt;</tt> is omitted, the archive is saved as <tt class="docutils literal"><span class="pre">&lt;commit-reference&gt;.tar.gz</span></tt>.</p>
376+
</dd>
369377
<dt><strong>git-status-u</strong></dt>
370378
<dd><p class="first"><em>Usage:</em> <tt class="docutils literal">git <span class="pre">status-u</span></tt></p>
371379
<ul class="simple">

README.rst

+20-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@
2020

2121
Designed to finish up a local topic/feature branch
2222

23-
**git-move-commits**
24-
*Usage:* ``git move-commits <num-commits> <correct-branch>``
25-
26-
* Moves the last ``num-commits`` commits to ``correct-branch``
27-
* If ``correct-branch`` doesn't exist, the script creates it
28-
* if ``correct-branch`` does exist, the script merges the commits
29-
30-
If you commit to the wrong branch (especially ``master``), this script
31-
will fix that for you.
32-
3323
**git-pull-branch**
3424
*Usage:* ``git pull-branch <branchname>``
3525

@@ -46,6 +36,26 @@
4636
A simple shortcut to get a local branch on a server without having to
4737
execute three different commands
4838

39+
**git-move-commits**
40+
*Usage:* ``git move-commits <num-commits> <correct-branch>``
41+
42+
* Moves the last ``num-commits`` commits to ``correct-branch``
43+
* If ``correct-branch`` doesn't exist, the script creates it
44+
* if ``correct-branch`` does exist, the script merges the commits
45+
46+
If you commit to the wrong branch (especially ``master``), this script
47+
will fix that for you.
48+
49+
**git-branch-from**
50+
*Usage:* ``git branch-from <commit-reference> <new-branch-name>``
51+
52+
If you made several commits to a branch (especially ``master``), and in retrospect, you really should have been doing that on a new branch, this will create a new branch from the ``commit-reference`` and reset current branch to the ``commit-reference``.
53+
54+
**git-export**
55+
*Usage:* ``git export <commit-reference> [<filename>]``
56+
57+
Exports a tar-gzipped archive of the ``commit-reference``. If ``<filename>`` is omitted, the archive is saved as ``<commit-reference>.tar.gz``.
58+
4959
**git-status-u**
5060
*Usage:* ``git status-u``
5161

git-export

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# Called as git export <commit-reference> [<filename>]
4+
#
5+
# Performs a git-archive, gzips it and names it <commit-reference>.tar.gz
6+
# or names it <filename> if included.
7+
8+
if [ -z $1 ]
9+
then
10+
echo "You need to specify a commit-reference to export."
11+
echo "Usage: git export commit-reference [filename]"
12+
exit 1
13+
else
14+
COMMIT=$1
15+
fi
16+
17+
if [ -z $2 ]
18+
then
19+
FILENAME="$COMMIT.tar.gz"
20+
else
21+
FILENAME=$2
22+
fi
23+
24+
git archive $COMMIT | gzip > $FILENAME

0 commit comments

Comments
 (0)