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