Carl
Carl

Reputation: 135

Export github repository

I have a project I am working on that is currently on in a repository on my GitHub.
I am doing as a part of my degree, I will be shortly handing it over to the client

I was wondering if there is a way to export the entire repository including all the branches and related history so that it can be stored prior to handing on to future developer?

Upvotes: 11

Views: 10172

Answers (2)

Vy Do
Vy Do

Reputation: 52774

(1) Use git archive (for backup one branch) like the below command (Suppose you are inside Git local repository):

git archive master --format=zip --output=java_exmamples.zip

you will see file java_exmamples.zip (in the same folder) is the backup of master branch.


(2) Use git bundle (for backup all branches)

A real example:

git clone --mirror https://github.com/donhuvy/java_examples.git
cd java_examples.git/
git bundle create repo.bundle --all

repo.bundle is the file what you need (full back up) in the same directory.

How to restore from file repo.bundle:

git clone repo.bundle

Reference

https://git-scm.com/docs/git-archive

https://git-scm.com/docs/git-bundle

http://rypress.com/tutorials/git/tips-and-tricks#bundle-the-repository

Upvotes: 16

VonC
VonC

Reputation: 1330102

Beside forking it (which is a clone on the remote side: GitHub), you can also export it as a bundle.

From your own local clone, you can type (using git bundle)

git bundle create /tmp/myrepo.bundle --all

That will give you one file (easy to copy around), from which you can clone back your repo at any time.

cd /a/new/path
git clone /tmp/myrepo.bundle myrepo
cd myrepo
pwd
  /a/new/path/myrepo

Upvotes: 4

Related Questions