git - Fetching remote remotes and remote remote branches -
i'd fetch remote branches of remote repository.
so, example, in situation —
$ cd alpha $ git remote beta $ git branch -a master remotes/alpha/master $ cd ../beta $ git remote gamma $ git branch -a master remotes/gamma/slave
— i'd fetch gamma
's slave
branch alpha
repository going through beta
. presumably add gamma
remote of alpha
, use gamma/slave
new branch's refspec. don't want create local tracking branch. don't have filesystem access beta
or gamma
, unlike in example.
this sort of thing can done $ git clone --mirror
, there way in already-existing repo?
it looks setting non-default refspec me partway there.
for example, consider setup:
initialize
gamma
$ (mkdir gamma; cd gamma; git init; touch readme; git add readme; git commit -m 'initialized slave.'; git branch -m slave; echo) initialized empty git repository in /tmp/test-git/gamma/.git/ [master (root-commit) 0cebd50] initialized slave. 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 readme
initialize
beta
, addgamma
remote:$ (mkdir beta; cd beta; git init; touch readme; git add readme; git commit -m 'initialized master.'; git remote add gamma ../gamma; git fetch gamma echo; echo "in repo $(basename $pwd):"; git branch -a; echo) initialized empty git repository in /tmp/test-git/beta/.git/ [master (root-commit) f6512e1] initialized master. 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 readme warning: no common commits remote: counting objects: 3, done. remote: total 3 (delta 0), reused 0 (delta 0) unpacking objects: 100% (3/3), done. ../gamma * [new branch] slave -> gamma/slave in repo beta: * master remotes/gamma/slave
clone
beta
makealpha
:$ git clone beta alpha initialized empty git repository in /tmp/test-git/alpha/.git/ $ cd alpha; git branch -a * master remotes/origin/head -> origin/master remotes/origin/master
now fierce:
# avoid errors pulling active branch. $ git checkout origin/master | head -3 # intentionally acquire severed head note: checking out 'origin/master'. in 'detached head' state. can around, make experimental $ git fetch origin '+refs/*:refs/*' # pour steroids open esophagus /tmp/test-git/beta * [new branch] gamma/slave -> gamma/slave $ git branch -a * (no branch) master remotes/gamma/slave remotes/origin/head -> origin/master remotes/origin/master $ git remote origin
so doing `$ git fetch '+refs/:refs/' pull in branch itself, not update configuration items constitute remote belongs to.
interestingly, setting tracking branch remoteless remote branch cause start tracking own repo:
$ git branch --track slave gamma/slave branch slave set track local ref refs/remotes/gamma/slave. $ git config -l | grep '^remote\|^branch' remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* remote.origin.url=/tmp/test-git/beta branch.master.remote=origin branch.master.merge=refs/heads/master branch.slave.remote=. branch.slave.merge=refs/remotes/gamma/slave
i think doesn't work.
$ git checkout slave switched branch 'slave' $ git fetch . * remote branch gamma/slave -> fetch_head $ git fetch . * remote branch gamma/slave -> fetch_head
Comments
Post a Comment