2

There are some similar posts on SO related to git repository export and import, but all answers are not complete. So I am asking separate question here.

I am using EGIT in eclipse to work on git SCM.

How I can export the git repository to a zip file/folder(with all branches, tags and history) and import the same repository back in Eclipse?

I tried,

git archive HEAD --format=zip >~/abc.zip but while importing back in eclipse it's not working.

Are there any other ways for importing and exporting git repositories?


Edit

After looking at @VonC answer, I did this

git bundle create ~/abc.bundle --all git bundle list-heads ~/abc.bundle <pre> refs/heads/master refs/remotes/origin/branch1 refs/remotes/origin/branch1 refs/remotes/origin/branch3 refs/remotes/origin/master refs/remotes/origin/branch4 ..... refs/tags/tag1 refs/tags/tag2 refs/tags/tag3 ....</pre> git clone -b master ~/abc.bundle ~/newrepo/xyz/ 

But when I tried to import this git repo in Eclipse I keep getting only the master branch as while cloning I used master. Is it possible to clone all the branches in a single command?

1 Answer 1

2

Another way, which actualy does preserve the full history, is git bundle (see "Backup a Local Git Repository").

cd /path/to/your/repo git bundle create ../repo.bundle --all 

However, you will have to clone it again before EGit can see the exported/imported repo, because EGit doesn't support yet bundle files as repo.


when I tried to import this git repo in eclipse I am getting only master branch as while cloning I used master. Is it possible to clone all the branches in a single command?

Do a git branch -avvv in your cloned repo (the one cloned from the bundle).
You should see all your remote branches (origin/xxx).

Eclipse should then be able to list and make a new branch based on one of those remote tracking branches as in "How do I create a proper new local and remote branch combination in EGit?".

To restore all the branches from the bundle, see "restore all refs from git bundle":
You need to mirror clone it.

Sign up to request clarification or add additional context in comments.

4 Comments

Edited my post, added details
@ChandrayyaGK I meant git branch -avvv, not git br (which is an alias of mine)
No not works. Executed git branch -avvv then git branch -a the results are:<br>master remotes/origin/HEAD -> origin/master remotes/origin/master
@ChandrayyaGK then mirror clone it: that clone --mirror will have all the remote tracking branches in it. see stackoverflow.com/a/12003661/6309.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.