I am adding a submodule to my project which contains another git repo.
To get the module I ran:
git submodule add git://github.com/biakaveron/debug-toolbar.git modules/debug-toolbar
Then ran:
git submodule update --init --recursive
Which generated this error:
fatal: Not a git repository: ../../../../../../..//d/websites/project/.git/modules/modules/debug-toolbar/modules/vendor/firephp
Failed to recurse into submodule path 'modules/debug-toolbar'
I have run into similar problems before. Previously I just added the submodule and then re-cloned the project with the recursive flag (git clone --recursive project.git) which works. However it would be easier if I could get the submodule to pull in recursively in the first place. Is there a way to do this?
One possible cause could be the fact that github.com/cadorn/firephp-libs mentions:
THIS PROJECT HAS MOVED TO THE FOLLOWING REPOSITORIES:
https://github.com/firephp/firephp
https://github.com/firephp/firephp-core
So you might want to update the .gitmodules file of debug-toolbar first (after a git submodule update --init, without the --recursive part), and then, try again the git submodule update --init --recursive)
The OP did:
committing, then a recursive clone - which worked.
Original answer:
It seems that the path definition for one of the submodules (in the .gitmodules file) is not correct:
Being a relative path, it won't resolve successfully when cloned/updated by a git submodule --recursive command done from a parent repo for which said relative path is invalid.
Related
I am trying to clone this repository:
https://github.com/electronicarts/EASTL
But almost all of the submodules are adding this repository as a submodule! (see: https://github.com/electronicarts/EASTL/tree/master/test/packages)
This creates an infinite recursion, and it keeps cloning forever.
Is there a solution for this?!
The infinite recursion happens if you specify the --recurse-submodules option to git clone. As a workaround, you could:
Clone the repository without submodules:
$ git clone git#github.com:electronicarts/EASTL.git
$ cd EASTL
And then initialize and update the submodules without recursion:
$ git submodule update --init
I have added a submodule to one of my repositories hosted on GitLab. In my browser GitLab displays the correct submodule#commit entry and the .gitmodules also looks okay. However, if I clone the repository using --recurse-submodules, the folder which should contain the submodule is empty.
I realize that this is impossible to diagnose without further information (which I cannot provide) but all I'd like to know here is how to go about debugging this myself since git fails to provide any information on what's gone wrong.
EDIT: I believe I've figured it out. I'm on Windows (which I forgot to tag, sorry about that) and my .gitmodules contained submodule paths using escaped backslashes (which I thought was correct), manually changing those to forward slashes fixed the problem.
You can try this after cloning you repository:
$ git submodule init
$ git submodule update --remote
When I run this, files changes from the copied /first-repo are being ignored by bundle exec. How can I make sure that the files from /first-repo are included?
#!/bin/bash
cd /first-repo;
git pull;
cd /second-repo;
git pull;
# copy folder from first repo to second repo
cp -rf /first-repo /second-repo/destination_folder;
git add -A;
git commit -m "update destination folder from first repo";
git push;
# build
bundle exec rake build_site;
Sounds like you could use a Git Submodule.
Continuing the example, in second-repo you can instantiate a git submodule of first-repo to get the whole first-repo repository as a directory inside second-repo. You can also use the Jekyll config include variable to specify what files from first-repo to use in second-repo.
I'm writing my own git post-receive hook in ruby, and it resembles something like this:
if !File.exists?(rep_dir+repo)
puts "Cloning repository #{repo} into #{rep_dir}."
`cd #{rep_dir}; sudo git clone file:////home/git/repositories/#{repo}.git`
exit
end
This hook is setup in gitolite common hooks, so when I push configurations for a new repository, I clone it right away to a new location.
I also loop for each project in gitolite config to check if the repository exists for each project, but that's not where I'm having problems.
My issue is, whenever this script runs I get:
remote: cd: 1: can't cd to /home/<somedir>/repositories/
remote: Cloning repository gitolite-admin into /home/<somedir>/repositories/.
The repository was not cloned to the target directory after the hook ran. I read about unsetting the GIT_DIR environment variable, but I had no success.
You don't have to cd anywhere when you are cloning.
You can simply add the destination path as a parameter to clone command.
git clone file:///xxx /path/where/to/clone
(Make sure the destination path doesn't exist, or the git will refuse to clone there)
I have an iOS project in Xcode 4, that is using Git. Now I want to add the MKStoreKit framework to my project. It is already under version control using Git and a public repo. I'd like to include it in my project, and allow my project's git version control to do version control of the currently pulled version of MKStoreKit, while maintaining the ability to clone any updated MKStoreKit code with standard git ease. I see that a git submodule or subtree is probably what I need, but it seems like a real PITA. Is there not a simpler way?
So far any external code I add to my project I clone to a temp directory, then copy the individual files into my project. This feels like a kludgy way to do things.
Check out the submodules section of the Git book. They're not really all that bad.
If you have a git repository, and you want to add another repository as a subdirectory, you can do this:
git submodule add git://github.com/MugunthKumar/MKStoreKit.git mstorekit
Now you have a directory "mstorekit" inside your project that is actually the MStoreKit repository. If someone clones your repository, they'll start with an empty "mstorekit" directory. Running:
git submodule init
git submodule update
Will clone the MStoreKit repository. They'll end up with the HEAD of the MStoreKit repository at the same commit as the one checked in to your repository.
Updating MStoreKit would look like this:
cd mstorekit
git pull origin master
cd ..
git ci -m 'updated mstorekit to latest version'
There are some alternatives out there, including git-subtree, which I saw mentioned recently around here. I have no experience with it (whereas I've been reasonably happy working with submodules).