git branching
Here is a nice introduction to git. In particular the instructions for adding a branch worked quite well. For sparkrocket I wanted to create a new branch for testing. In the git-repos there was no branch so the question arises how to add a new branch and push it to the current repository.
Creating a local branch is easy:
git checkout -b test
I had made modifications so I checked them in after branching:
git commit -a
I then did a push all as indicated from the tutorial but if I remember correctly I didn’t indicate the repo I just did the “–all”
git push –all
Either way test was pushed to the sparkrocket repo on .0.8. But I also had a clone of the repo on my my other machine 0.133 and when I did a git pull the test branch was added and we can see it in the remotes:
wink@ic2d1:~/prgs/sparkrocket$ find . -iname ‘test’
./.git/logs/refs/remotes/origin/test
./.git/refs/remotes/origin/test
but not in heads as it is on .0.8:
root@saville-server:/var/www/sparkrocket# find . -name ‘test’
./.git/refs/heads/test
./.git/refs/remotes/origin/test
./.git/logs/refs/heads/test
./.git/logs/refs/remotes/origin/test
but it wasn’t in .git/refs/heads/test. After a few false starts it looks like the way to get it to be “visible” on 0.133 was to check it out and then add it as a branch.
git checkout c37c761d48bcf6cbb0d1cb987e074f86a587182a
git checkout -b test
This looks to have done the correct things, doing a find for test we see the same as on .0.8:
wink@ic2d1:~/prgs/sparkrocket$ find . -iname ‘test’
./.git/logs/refs/remotes/origin/test
./.git/logs/refs/heads/test
./.git/refs/remotes/origin/test
./.git/refs/heads/test
—Update
Didn’t quite work, after an additional modification on .0.8 I pushed the change to the repo and then pull it back down to .0.133. All was well but for the final step:
wink@ic2d1:~/prgs/sparkrocket$ git pull
remote: Generating pack…
remote: Done counting 7 objects.
Result has 4 objects.
remote: Deltifying 4 objects…
remote: 100% (4/4) done
remote: Total 4 (delta 3), reused 0 (delta 0)
Unpacking 4 objects…
100% (4/4) done
* refs/remotes/origin/test: fast forward to branch ‘test’ of git://192.168.0.8/sparkrocket
old..new: c37c761..d103e89
Warning: No merge candidate found because value of config option
“branch.test.merge” does not match any remote branch fetched.
No changes.
— Update 2007-10-28
Figured it out, turns out that even on 0.8 a “git pull” didn’t work and emitted the exact same message that there was no merge candidate. So I looked at .git/config and decided to add another branch section for test, that worked so the config file on 0.8 and 0.133 is:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git://192.168.0.8/sparkrocket.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "test"]
remote = origin
merge = refs/heads/test
So adding the [branch “test”] did the trick.