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

[PATCH] git-bundle - bundle objects and references for disconnected transfer.

From
Mark Levedahl <mdl123@verizon.net>
Date
Feb 14, 2007, 14:10 UTC
Message-ID
<11714622292295-git-send-email-mdl123@verizon.net>
In-Reply-To
<11714622292110-git-send-email-mdl123@verizon.net>

Some workflows require coordinated development between repositories on machines that can never be connected. This utility creates a bundle containing a pack of objects and associated references (heads or tags) that can be independently transferred to another machine, effectively supporting git-push like operations between disconnected systems.

Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
 git-bundle |   85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)
 create mode 100755 git-bundle
diff --git a/git-bundle b/git-bundle
new file mode 100755
index 0000000..1341885
--- /dev/null
+++ b/git-bundle
@@ -0,0 +1,85 @@
+#!/bin/sh
+# Create a bundle to carry from one git repo to another (e.g., "sneaker-net" based push)
+# git-bundle <git-rev-list args>
+# git-bundle --bare <git-rev-list args>
+# creates bundle.zip in current directory (can rename of course)
+#
+# The bundle includes all refs given (--all selects every ref in the repo).
+# and all of the commit objects needed subject to the list given.
+#
+# Objects to be packed are limited by specifying one or more of
+#   ^commit-ish    - indicated commits already at the target (can have more than one ^commit-ish)
+#   --since=xxx    - Assume target repo has all relevant commits earlier than xxx
+
+USAGE='git-bundle <options> <git-rev-list arguments>
+
+Creates a bundle of objects to be carried to a disconnected repository, bringing the target
+repository''s definition of one or more references up to date as selected by the
+<git-rev-list arguments>
+
+Options:
+    -h, --help        Print this help screen
+        --bare        Work in a bare repository
+    --output=f        Output to file f (default is bundle.zip)
+
+    examples
+        git-bundle master~10..master
+        git-bundle master next pu ^master~30 --output=mybundle.zip --bare'
+
+die() {
+	echo >&2 "$@"
+	exit 1
+}
+
+# pull out rev-list args vs program args, parse the latter
+gitrevargs=$(git-rev-parse --symbolic --revs-only $*) || exit 1
+myargs=$(git-rev-parse --no-revs $*) || exit 1
+
+bfile=bundle.zip
+for arg in $myargs ; do
+	case "$arg" in
+		--bare)
+			export GIT_DIR=.;;
+		-h|--h|--he|--hel|--help)
+			echo "$USAGE"
+			exit;;
+		--output=*)
+			bfile=${arg##--output=};;
+		-*)
+			die "unknown option: $arg";;
+		*)
+	esac
+done
+
+GIT_DIR=$(git-rev-parse --git-dir) || die "Not in a git directory"
+
+# find the refs to carry along and get sha1s for each.
+refs=
+for arg in $gitrevargs ; do
+	#ignore options and basis refs
+	case "$arg" in
+		^*) ;;
+		-*) ;;
+		*)
+			n=$(git-show-ref "$arg" | wc -l)
+			[ $n -eq 1 ] || die "ambiguous reference: $arg"
+			refs="$refs $arg"
+			;;
+	esac
+done
+[ -z "$refs" ] && die "No references specified, I don't know what to bundle."
+
+# put the refs into the bundle file
+[ -e "$bfile" ] && rm -f "$bfile" 2>/dev/null
+git-show-ref $refs > .gitBundleReferences
+zip -m "$bfile" .gitBundleReferences
+
+# add the pack file
+(git-rev-list --objects $gitrevargs | \
+	cut -b -40 | \
+	git pack-objects --all-progress --progress --stdout >.gitBundlePack) \
+	|| (rm -f "$bfile" ; exit)
+zip -m "$bfile" .gitBundlePack
+
+# done
+echo "Created $bfile"
-- 
1.5.0.rc3.24.g0c5e
Previous: Mark LevedahlNext: Mark Levedahl
Message 2 of 32 in “Scripts to use "bundles" for moving data between repositories”
  1. Mark LevedahlFeb 14, 2007
  2. git-bundle - bundle objects and references for disconnected transfer.Mark Levedahl, Feb 14, 2007
  3. git-unbundle - unbundle objects and references for disconnected transfer.Mark Levedahl, Feb 14, 2007
  4. Create a man page for git-bundle.Mark Levedahl, Feb 14, 2007
  5. Create a man page for git-unbundle.Mark Levedahl, Feb 14, 2007
  6. Shawn O. PearceFeb 14, 2007
  7. Mark LevedahlFeb 14, 2007
  8. Shawn O. PearceFeb 14, 2007
  9. Mark LevedahlFeb 14, 2007
  10. Nicolas PitreFeb 14, 2007
  11. Shawn O. PearceFeb 14, 2007
  12. Johannes SchindelinFeb 14, 2007
  13. Mark LevedahlFeb 14, 2007
  14. Mark LevedahlFeb 14, 2007
  15. Johannes SchindelinFeb 15, 2007
  16. Mark LevedahlFeb 15, 2007
  17. Johannes SchindelinFeb 15, 2007
  18. Johannes SchindelinFeb 15, 2007
  19. Mark LevedahlFeb 15, 2007
  20. Johannes SchindelinFeb 15, 2007
  21. Mark LevedahlFeb 16, 2007
  22. Johannes SchindelinFeb 16, 2007
  23. Mark LevedahlFeb 16, 2007
  24. Matthieu MoyFeb 14, 2007
  25. Mark LevedahlFeb 14, 2007
  26. Johannes SchindelinFeb 14, 2007
  27. Junio C HamanoFeb 14, 2007
  28. Mark LevedahlFeb 14, 2007
  29. Junio C HamanoFeb 14, 2007
  30. Mark LevedahlFeb 14, 2007
  31. Junio C HamanoFeb 14, 2007
  32. Junio C HamanoFeb 14, 2007

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.