# Git-ipfs - A helper script to push git repositories to IPFS

**URL:** <https://discuss.ipfs.tech/t/git-ipfs-a-helper-script-to-push-git-repositories-to-ipfs/1182>\
**Category:** Ecosystem and Usage\
**Created:** [October 1, 2017, 10:08pm UTC](https://discuss.ipfs.tech/t/git-ipfs-a-helper-script-to-push-git-repositories-to-ipfs/1182 "2017-10-01T22:08:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![singpolyma](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/singpolyma/32/351_2.png) [@singpolyma](https://discuss.ipfs.tech/u/singpolyma)\
**Post date:** [October 1, 2017, 10:08pm UTC](https://discuss.ipfs.tech/t/git-ipfs-a-helper-script-to-push-git-repositories-to-ipfs/1182/1 "2017-10-01T22:08:55Z")

</div>

Inspired by the “git” example in the docs, I’ve built this:

```
#!/bin/sh

set -e

TMP="$(mktemp -d)"
git clone -q --bare . "$TMP"
cd "$TMP"
git update-server-info
if [objects/pack/*.pack != 'objects/pack/*.pack']; then
	cat objects/pack/*.pack | git unpack-objects
	rm -f objects/pack/*
fi
HASH="$(ipfs add -Qr .)"
rm -rf "$TMP"

if [-n "$1"]; then
	ipfs name publish --key=$1 "/ipfs/$HASH"
else
	echo "$HASH"
fi

```

Usage: from inside any git working directory, type `git ipfs` to “push” the whole repository to IPFS. Type `git ipfs <key-name>` to push to IPFS and then assign the result to the given IPNS key
