First of all, I know how I can update my Bare Repository. I want to know why when my current repository is bare
and I fetch
from a remote repository, git creates remote (tracking) branches
except of when I fetch from origin
?
I tried this experiment:
I have three directories in current directory: origin
, bare_clone
and remote
. Now:
$ cd ./origin
$ git init
$ cat > 1
^Z
$ git add 1
$ git commit -m "add 1 in initial commit"
$ cd ../bare_clone
$ git clone --bare ../origin
$ cd ../remote
$ git init
$ cat > 1
^Z
$ git add 1
$ git git commit -m "add 1 in initial commit"
$ git branch test
$ cd ../bare_clone/origin.git/
$ git remote add remote_name ../../remote/
____________________________________________
$ git fetch remote_name
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../../remote
* [new branch] master -> remote_name/master
* [new branch] test -> remote_name/test
____________________________________________
$ git branch -a
* master
remotes/remote_name/master
remotes/remote_name/test
____________________________________________
$ cd ../../origin/
$ git branch origin_test_branch
____________________________________________
$ cd ../bare_clone/origin.git/
t$ git fetch origin
From path/to/bare_clone/../origin
* branch HEAD -> FETCH_HEAD
____________________________________________
$ git branch -a
* master
remotes/remote_name/master
remotes/remote_name/test
You can see two remote branches are created for tracking branches of remote_name
repository but there is no remote branch for tracking branch origin_test_branch
of origin
.