mike
mike

Reputation: 836

Git: Pull everything from bare usb remote

I try to set up a usb-hdd to be my mobile version of all my local repos. Everything I use is not online and by now not shared. So the only collaborator is me. So the goal is to save my whole progress and clone it from the usb on some other machine. The important part is, that all the tags and especially branches are pushed, pulled aswell. And I don't really want to do something for each branch manually. By now I cloned my repos using

$ cd /Volumes/usb
$ git clone --mirror /path/to/working/repo

and now I want to pull everything from that bare (as far as I know mirror implies bare) repo. So I go to another machine/folder and do a

$ git clone file:///Volumes/usb/repo.git

and the master branch is cloned locally and I get a working directory. All the other branches however are just on the remote (the bare usb repo) and don't get pulled. If I use git branch -r I can see all of them on the remote, but pulling doesn't do anything.

$ git br -a
* devel
  remotes/origin/HEAD -> origin/devel
  remotes/origin/devel
  remotes/origin/master

$ git pull origin master
From /test/repo
* branch            master     -> FETCH_HEAD
Already up-to-date.
$ git br -a
* devel
  remotes/origin/HEAD -> origin/devel
  remotes/origin/devel
  remotes/origin/master

Nothing changed and it doesn't set up a local branch. The whole point would even be to set up all remote branches as local branches. I really want to start, where I left off.

Upvotes: 2

Views: 348

Answers (1)

VonC
VonC

Reputation: 1326746

All the other branches however are just on the remote (the bare usb repo) and don't get pulled

They are pulled.
And you see them, not on "remote", but in your local repo in the namespace origin.

If you really want to have those remote tracking branches as branches, see the onle-liner I use at "git pull all branches from remote repository"

$ remote=origin ; for brname in `git branch -r | grep $remote | grep -v master | grep -v HEAD | awk '{gsub(/[^\/]+\//,"",$1); print $1}'`; do git branch -t $brname $remote/$brname ; done 

Once all local branches are tracking remote tracking branches, you would still have to use a script if you were to pull all branches.

Upvotes: 1

Related Questions