github and submodule weirdness
So I’m not a git or github master by any means. For the most part, I know enough commands to get by and to get myself into trouble every now and then. My experience so far has been good with git and github, but today I ended up banging my head on a wall while I tried to figure out what was going on. Follow me, on this little trip down a rabbit hole. Maybe someone can explain what’s going on here.
First I generate a rails app:
lappy:tmp bsmith$ rails foo
Then I add restful authentication, using the command listed in the install documentation:
lappy:tmp bsmith$ cd foo/
lappy:foo bsmith$ cd vendor/plugins/
lappy:plugins bsmith$ git clone git://github.com/technoweenie/restful-authentication.git restful_authentication
Initialized empty Git repository in /Users/bsmith/tmp/foo/vendor/plugins/restful_authentication/.git/
remote: Counting objects: 1741, done.
remote: Compressing objects: 100% (590/590), done.
remote: Total 1741 (delta 1010), reused 1641 (delta 957)
Receiving objects: 100% (1741/1741), 733.93 KiB | 831 KiB/s, done.
Resolving deltas: 100% (1010/1010), done.
Then I add everything to git:
lappy:plugins bsmith$ cd ../..
lappy:foo bsmith$ git init
Initialized empty Git repository in /Users/bsmith/tmp/foo/.git/
lappy:foo bsmith$ git add .
lappy:foo bsmith$ git commit -m ‘init’
[master (root-commit) f63c7ea] init
43 files changed, 8462 insertions(+), 0 deletions(-)
create mode 100644 README
create mode 100644 Rakefile
…[followed by lots more output]
Then I pushed it to github:
lappy:foo bsmith$ git remote add github git@github.com:benjaminleesmith/submodule_test.git
lappy:foo bsmith$ git push github master
Counting objects: 64, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (56/56), done.
Writing objects: 100% (64/64), 79.32 KiB, done.
Total 64 (delta 10), reused 0 (delta 0)
To git@github.com:benjaminleesmith/submodule_test.git
* [new branch] master -> master
Next, I take a look at the vendor directory that got committed go github:
![]() |
| From screen shots |
I assume that the little folder icon with an arrow means that the restful authentication code is being hosted elsewhere… as a submodule maybe? The folder is not clickable, so I can’t see what’s inside… if there’s anything!
So my next step is to pull the project, say for a deployment on another system:
lappy:tmp bsmith$ mkdir bar
lappy:tmp bsmith$ cd bar/
lappy:bar bsmith$ git init
Initialized empty Git repository in /Users/bsmith/tmp/bar/.git/
lappy:bar bsmith$ git pull git://github.com/benjaminleesmith/submodule_test.git
remote: Counting objects: 64, done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 64 (delta 10), reused 0 (delta 0)
Unpacking objects: 100% (64/64), done.
From git://github.com/benjaminleesmith/submodule_test
* branch HEAD -> FETCH_HEAD
Then… I go searching for restful auth in this latest pull…
lappy:bar bsmith$ cd vendor/plugins/
lappy:plugins bsmith$ ls
restful_authentication
lappy:plugins bsmith$ cd restful_authentication/
lappy:restful_authentication bsmith$ ls
lappy:restful_authentication bsmith$
Yikes! The directory is there, but the contents are missing! I don’t know if this is a problem with the way I added restful auth to my local git repo, or if this is an issue with github. I noticed this when a production deployment was failing saying “uninitialized constant User::Authentication (NameError)” as if restful auth was no where to be found.
It seems less than intuitive to say the least. If anyone knows what’s going on here, leave me a comment please! Otherwise, my fix was to clone restful auth, then remove its git directory. This allowed me to push to github exactly what my local copy contained.



December 16th, 2009 at 12:22 am
Don’t use the command listed in the install documentation. Instead, use `script/plugin`, like so:
./script/plugin install git://github.com/technoweenie/restful-authentication.git
Also, have you checked out Thoughtbot’s clearance gem?
December 16th, 2009 at 6:53 am
Yeh… I think submodules (even if they worked) would be bad juju anyway.
I haven’t used clearance yet. I’ve used Auth Logic the project before last though, that was pretty easy.