I am doing a backup script for a local git repo. I looked through the possibilities, and chose bundle to do the task. The steps I have taken:
Create a new repo, do the initial commits
When i inspect the repo with
git branch -a
i get the following:* master
git bundle create ./test.bundle --all
By now when i inspect the bundle with git bundle list-heads
I get 2 references: 1 for HEAD and the other for refs/heads/master.
When I pull this bundle into a new repository with git clone
, the branches look like this:
*master
remotes/origin/HEAD -> remotes/origin/master
remotes/origin/master
Why does this happen? Is there a way to import only branches that where in the first repository without the remotes?
EDIT:
My question could have been a bit unclear. Here is what I would want to achieve:
- Have a repo with 2 branches, master and test.
- bundle all the branches (done with
git bundle --branches
as suggested) rm
the whole repo- Restore the repo with git clone. Unfortunately I have to give a branch parameter since I get the following error without it:
warning: remote HEAD refers to nonexistent ref, unable to checkout.
The only problem that arises is that I get the following branches after clone:
*master
remotes/origin/master
remotes/origin/test
Upon switching to test, I get a message that a new branch has been made. Is there a way to clone all branches so that it could look like the original repo?
*master
test