Okay, I have a use case which I think shouldn’t be too hard. Jean-François, my Montreal on Rails buddy, gave me a good hand, but I think there’s some interaction going on between Github and git-svn that causes friction…

I have a new project which I want to track using Git, but I also want to keep a push-only Subversion repository on Rubyforge.

So, I started like any old project:


1 $ svn checkout svn+ssh://fbos@rubyforge.org/var/svn/theproject
2 $ svn mkdir tags branches
3 $ newgem theproject
4 $ mv theproject trunk
5 $ svn add trunk
6 $ svn commit -m "New project layout"

Then, I imported that into a fresh Git repository:


1 $ git svn clone svn+ssh://fbos@rubyforge.org/var/svn/theproject -T trunk -t tags -b branches theproject

I then started coding and commiting using Git. All was well, and I was happy. Then, I pushed to Subversion, like any good developer should:


1 $ git svn dcommit

That worked well enough. Then, I was ready to have a public Git repository. I went to Github, where I have an account, and created a new repository. I then did:


1 $ git remote add github git@github.com:francois/theproject.git
2 $ git push github master

That gave me a couple of errors:


1 error: remote ‘refs/heads/master’ is not a strict subset of local ref
2 ‘refs/heads/master’. maybe you are not up-to-date and need to pull first?
3 error: failed to push to ‘git@github.com:francois/theproject.git’

After some discussion with Jean-François, he told me to have a separate branch on which to do development, and merge to master when I am ready to dcommit. So, I did:


1 $ git checkout -b mainline
2 # code again
3 $ git checkout master
4 $ git merge mainline
5 $ git svn dcommit

That works well enough. Now I want to push my mainline to Github. So I do:


1 $ git remote add github git@github.com:francois/theproject.git
2 $ git push github mainline
3 $ git push github mainline
4 updating ‘refs/heads/mainline’
5 from 0000000000000000000000000000000000000000
6 to 31d6eee71b00f829b8568937ab3adaaa8831205c
7 Generating pack…
8 Done counting 201 objects.
9 Deltifying 201 objects…
10 100% (201/201) done
11 Writing 201 objects…
12 100% (201/201) done
13 Total 201 (delta 100), reused 0 (delta 0)
14 refs/heads/mainline: 0000000000000000000000000000000000000000 -> 31d6eee71b00f829b8568937ab3adaaa8831205c

Great! It works. Except… The repository page on Github still shows I need to create the repository. Just for fun, without doing anything else I created a new empty Git repository, touched README, added that, remoted Github and pushed. Voilà, Github showed me the repository, with README being added.

Can anyone shed some light on this ? Here’s a reproduction recipe:


1 $ cat repro.sh
2 #!/bin/sh
3
4 rm -rf repos wc theproject
5 svnadmin create repos
6 svn checkout file:///`pwd`/repos wc
7 cd wc
8 svn mkdir tags branches
9 newgem theproject
10 mv theproject trunk
11 svn add trunk
12 svn commit -m "Initial revision"
13 cd ..
14 git svn clone file:///`pwd`/repos theproject
15 cd theproject
16 echo "The new revision" > README
17 git add README
18 git commit -a -m "New README content"
19 git checkout -b mainline
20 git checkout master
21 git svn dcommit
22 git checkout mainline
23 echo "More content" >> README
24 git commit -a -m "More README goodness"
25 git remote add github git@github.com:francois/theproject.git
26 git push github mainline
27 git checkout master
28 git merge mainline
29 git svn dcommit

And here’s a sample bash +x run:


1 + rm rf repos wc theproject
2 + svnadmin create repos
3 + pwd
4 + svn checkout file:////home/francois/src/repro/repos wc
5 Checked out revision 0.
6 + cd wc
7 + svn mkdir tags branches
8 A tags
9 A branches
10 + newgem theproject
11 create
12 create config
13 create doc
14 create lib
15 create log
16 create script
17 create tasks
18 create test
19 create tmp
20 create lib/theproject
21 create History.txt
22 create License.txt
23 create Rakefile
24 create README.txt
25 create setup.rb
26 create lib/theproject.rb
27 create lib/theproject/version.rb
28 create config/hoe.rb
29 create config/requirements.rb
30 create log/debug.log
31 create tasks/deployment.rake
32 create tasks/environment.rake
33 create tasks/website.rake
34 create test/test_helper.rb
35 create test/test_theproject.rb
36 dependency install_website
37 create website/javascripts
38 create website/stylesheets
39 exists script
40 exists tasks
41 create website/index.txt
42 create website/index.html
43 create script/txt2html
44 force tasks/website.rake
45 dependency plain_theme
46 exists website/javascripts
47 exists website/stylesheets
48 create website/template.rhtml
49 create website/stylesheets/screen.css
50 create website/javascripts/rounded_corners_lite.inc.js
51 dependency install_rubigen_scripts
52 exists script
53 create script/generate
54 create script/destroy
55 create Manifest.txt
56 readme readme
57 Important
58 =====
59
60 * Open config/hoe.rb
61 * Update missing details (gem description, dependent gems, etc.)
62 + mv theproject trunk
63 + svn add trunk
64 A trunk
65 A trunk/Manifest.txt
66 A trunk/History.txt
67 A trunk/doc
68 A trunk/setup.rb
69 A trunk/tmp
70 A trunk/test
71 A trunk/test/test_theproject.rb
72 A trunk/test/test_helper.rb
73 A trunk/tasks
74 A trunk/tasks/deployment.rake
75 A trunk/tasks/website.rake
76 A trunk/tasks/environment.rake
77 A trunk/lib
78 A trunk/lib/theproject.rb
79 A trunk/lib/theproject
80 A trunk/lib/theproject/version.rb
81 A trunk/script
82 A trunk/script/txt2html
83 A trunk/script/destroy
84 A trunk/script/generate
85 A trunk/Rakefile
86 A trunk/website
87 A trunk/website/stylesheets
88 A trunk/website/stylesheets/screen.css
89 A trunk/website/javascripts
90 A trunk/website/javascripts/rounded_corners_lite.inc.js
91 A trunk/website/index.txt
92 A trunk/website/template.rhtml
93 A trunk/website/index.html
94 A trunk/log
95 A trunk/log/debug.log
96 A trunk/config
97 A trunk/config/requirements.rb
98 A trunk/config/hoe.rb
99 A trunk/License.txt
100 A trunk/README.txt
101 + svn commit -m ‘Initial revision’
102 Adding branches
103 Adding tags
104 Adding trunk
105 Adding trunk/History.txt
106 Adding trunk/License.txt
107 Adding trunk/Manifest.txt
108 Adding trunk/README.txt
109 Adding trunk/Rakefile
110 Adding trunk/config
111 Adding trunk/config/hoe.rb
112 Adding trunk/config/requirements.rb
113 Adding trunk/doc
114 Adding trunk/lib
115 Adding trunk/lib/theproject
116 Adding trunk/lib/theproject/version.rb
117 Adding trunk/lib/theproject.rb
118 Adding trunk/log
119 Adding trunk/log/debug.log
120 Adding trunk/script
121 Adding trunk/script/destroy
122 Adding trunk/script/generate
123 Adding trunk/script/txt2html
124 Adding trunk/setup.rb
125 Adding trunk/tasks
126 Adding trunk/tasks/deployment.rake
127 Adding trunk/tasks/environment.rake
128 Adding trunk/tasks/website.rake
129 Adding trunk/test
130 Adding trunk/test/test_helper.rb
131 Adding trunk/test/test_theproject.rb
132 Adding trunk/tmp
133 Adding trunk/website
134 Adding trunk/website/index.html
135 Adding trunk/website/index.txt
136 Adding trunk/website/javascripts
137 Adding trunk/website/javascripts/rounded_corners_lite.inc.js
138 Adding trunk/website/stylesheets
139 Adding trunk/website/stylesheets/screen.css
140 Adding trunk/website/template.rhtml
141 Transmitting file data ……………………
142 Committed revision 1.
143 + cd ..
144 +
pwd
145 + git svn clone file:////home/francois/src/repro/repos theproject
146 Initialized empty Git repository in .git/
147 A trunk/History.txt
148 A trunk/test/test_helper.rb
149 A trunk/test/test_theproject.rb
150 A trunk/License.txt
151 A trunk/log/debug.log
152 A trunk/Rakefile
153 A trunk/setup.rb
154 A trunk/website/template.rhtml
155 A trunk/website/index.txt
156 A trunk/website/javascripts/rounded_corners_lite.inc.js
157 A trunk/website/index.html
158 A trunk/website/stylesheets/screen.css
159 A trunk/Manifest.txt
160 A trunk/script/txt2html
161 A trunk/script/destroy
162 A trunk/script/generate
163 A trunk/config/requirements.rb
164 A trunk/config/hoe.rb
165 A trunk/tasks/deployment.rake
166 A trunk/tasks/website.rake
167 A trunk/tasks/environment.rake
168 A trunk/lib/theproject/version.rb
169 A trunk/lib/theproject.rb
170 A trunk/README.txt
171 W: empty_dir: branches
172 W: +empty_dir: tags
173 W: +empty_dir: trunk/doc
174 W: +empty_dir: trunk/tmp
175 r1 = 01d09dc543711efb5bbd39e71ea2d1fe12516926 (git-svn)
176
177 Checked out HEAD:
178 file:////home/francois/src/repro/repos r1
179 + cd theproject
180 + echo ‘The new revision’
181 + git add README
182 + git commit -a -m ‘New README content’
183 Created commit 16eaad5: New README content
184 1 files changed, 1 insertions(
), 0 deletions(
)
185 create mode 100644 README
186 + git checkout b mainline
187 Branch mainline set up to track local branch refs/heads/master.
188 Switched to a new branch "mainline"
189 + git checkout master
190 Switched to branch "master"
191 + git svn dcommit
192 A README
193 Committed r2
194 A README
195 r2 = 5b2c01dde36111a37f942d9fb6670689089ad9ed (git-svn)
196 No changes between current HEAD and refs/remotes/git-svn
197 Resetting to the latest refs/remotes/git-svn
198 + git checkout mainline
199 Switched to branch "mainline"
200 + echo ‘More content’
201 + git commit -a -m ‘More README goodness’
202 Created commit 49df2b5: More README goodness
203 1 files changed, 1 insertions(+), 0 deletions(
)
204 + git remote add github git@github.com:francois/theproject.git
205 + git push github mainline
206 error: remote ‘refs/heads/mainline’ is not a strict subset of local ref ‘refs/heads/mainline’. maybe you are not up-to-date and need to pull first?
207 error: failed to push to ‘git@github.com:francois/theproject.git’
208 + git checkout master
209 Switched to branch "master"
210 + git merge mainline
211 Auto-merged README
212 CONFLICT (add/add): Merge conflict in README
213 Automatic merge failed; fix conflicts and then commit the result.
214 + git svn dcommit
215 No changes between current HEAD and refs/remotes/git-svn
216 Resetting to the latest refs/remotes/git-svn
217 README: needs update

I have a passing interest in Git. I haven’t migrated my projects over to it now, but am looking into it. Just for fun, I googled “ruby git”, and I found Ruby/Git. I thought more people should know about this.

Hmmm, I know Subversion doesn’t do it any better, but I was led to believe Git tracked directory renames. At least, it didn’t behave as I expected. Here’s a reproduction recipe:

repro.sh

1 #!/bin/sh
2 # This is repro.sh — use at your own risks
3 rm -rf recipe > /dev/null
4 mkdir recipe
5 cd recipe
6 git init
7 mkdir lib
8 echo "v1" > lib/main.rb
9 git add lib/
10 git commit -m "initial version"
11 git checkout -b perf
12 echo "v2" >> lib/main.rb
13 git commit —all -m "perf improvements"
14 echo "v1" > lib/helper.rb
15 git add lib/helper.rb
16 git commit -m "new file"
17 git checkout master
18 git mv lib lib0
19 git commit -m "renamed"
20 git checkout perf
21 git merge master
22 find | grep -v .git


1 $ . repro.sh
2 /home/francois/src/recipe
3 Initialized empty Git repository in .git/
4 Created initial commit a50ea59: initial version
5 1 files changed, 1 insertions(), 0 deletions(-)
6 create mode 100644 lib/main.rb
7 Switched to a new branch "perf"
8 Created commit 73d3379: perf improvements
9 1 files changed, 1 insertions(
), 0 deletions(-)
10 Created commit 01c0e0e: new file
11 1 files changed, 1 insertions(), 0 deletions(-)
12 create mode 100644 lib/helper.rb
13 Switched to branch "master"
14 Created commit 66ac898: renamed
15 2 files changed, 1 insertions(
), 1 deletions(-)
16 delete mode 100644 lib/main.rb
17 create mode 100644 lib0/main.rb
18 Switched to branch "perf"
19 Merge made by recursive.
20 {lib => lib0}/main.rb | 0
21 1 files changed, 0 insertions(+), 0 deletions(-)
22 rename {lib => lib0}/main.rb (100%)
23 .
24 ./lib
25 ./lib/helper.rb
26 ./lib0
27 ./lib0/main.rb

In prose, here’s what I did:

  • Initial development was in lib/main.rb
  • Then, I branched master to create a perf branch
  • On the perf branch, I added lib/helper.rb, and modified lib/main.rb
  • Back on master, I renamed lib/ to lib0/
  • Back on perf, I merged from master

What I expected to see is a move of lib/helper.rb and lib/main.rb to lib0/. Oh well, I don’t rename directories that often anyway. It’s more of a caveat than anything else.

At Montreal on Rails this evening, Jean-François Couture presented Git. I installed it on my Ubuntu Desktop machine, and I found that gitk was horrible to look at. Even after following Jean-François’ Various Tips For Setting Up Git: Improve Gitk Look And Get Bash Completion, gitk wasn’t really up to snuff with the rest of my UI.

On the Git home page, I found a reference to qgit, a much nicer looking application. Install and see for yourself.

Search

Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend

Links

Projects I work on

Projects I worked on