{"thread":{"id":"35722","subject":"submodules","startedAt":"2014-01-23T08:38:49Z","lastAt":"2014-01-23T17:20:14Z","messageCount":2,"participants":["shawn wilson","W. Trevor King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"233590","messageId":"CAH_OBicG4bLWu_C=uF6bTzzdJP5SSZ=odQF-qsP4n+VvAN4nrQ@mail.gmail.com","threadId":"35722","inReplyTo":null,"subject":"submodules","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2014-01-23T08:38:49Z","receivedAt":"2014-01-23T08:38:49Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"I've got a git repo that just contains a bunch of small projects\n(scripts, configs, etc). The idea was (is) to make it so that each\nproject is tracked seperately (different branches, not needing to\nfilter out logs for unrelated commits). And it works great for that.\nThe problem is that I guess I don't know how to manage it and keep\nstumbling and tripping over myself here.\n\nMy issue is in trying to update the submodules, I'm getting:\n % git submodule update --init\n                                                gits/kt (master ⚡)\nswlap1\nfatal: reference is not a tree: 98f1e9f99fca32ab3de901219eb2f600d38ab3a5\nUnable to checkout '98f1e9f99fca32ab3de901219eb2f600d38ab3a5' in\nsubmodule path 'repo_a'\n\nOk, so a bit of googling and I found this:\nhttp://stackoverflow.com/questions/13425298/git-submodule-update-fatal-error-reference-is-not-a-tree\nOk, so update the repo that contains the submodules every time you\npush from a sub repo? How / where do I create a hook to do this?\n\nAnd then:\nhttp://stackoverflow.com/questions/2155887/git-submodule-head-reference-is-not-a-tree-error\nSo, the first example didn't really work:\n % cd repo_a\n                                            gits/kt (master ⚡) swlap1\n % git checkout 98f1e9\n                                              kt/repo_a (master)\nswlap1\nerror: pathspec '98f1e9' did not match any file(s) known to git.\n\nSo, at this point I realized I have pushed from two repos (maybe\nothers have as well) and not updated the repo of submodules. So, as\nlong as the issue is just with this one repo, I'm ok with loosing a\nlittle data (not much has changed in a while and maybe I'll go and\nfind the blobs and merge them back in later). So I try the other\nmethod:\n % git log --oneline -p -- repo_a\n                                            gits/kt (master ⚡) swlap1\n7911a1e Bump.\ndiff --git a/repo_a b/repo_a\nindex 206635e..98f1e9f 160000\n--- a/repo_a\n+++ b/repo_a\n@@ -1 +1 @@\n-Subproject commit 206635eed8b94e4133a7689b34a570e2fb0b6069\n.......\n % git checkout d92f592- -- repo_a\n                                            gits/kt (master ⚡) swlap1\nfatal: invalid reference: d92f592-\n\n\n\nSo, (after this is solved) is there a post hook (not even sure where\nsuch a thing would go) after pushing from a submodule repo (maybe a\nconcatination of commit messages or something) so that this stays in\nsync and I never have to think about this again (though I think I'll\nremember after winning this fight).\n"},{"id":"233602","messageId":"20140123172014.GS29063@odin.tremily.us","threadId":"35722","inReplyTo":"CAH_OBicG4bLWu_C=uF6bTzzdJP5SSZ=odQF-qsP4n+VvAN4nrQ@mail.gmail.com","subject":"Re: submodules","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2014-01-23T17:20:14Z","receivedAt":"2014-01-23T17:20:14Z","isPatch":false,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"On Thu, Jan 23, 2014 at 03:38:49AM -0500, shawn wilson wrote:\n> My issue is in trying to update the submodules, I'm getting:\n>  % git submodule update --init\n>                                                 gits/kt (master ⚡)\n> swlap1\n> fatal: reference is not a tree: 98f1e9f99fca32ab3de901219eb2f600d38ab3a5\n> Unable to checkout '98f1e9f99fca32ab3de901219eb2f600d38ab3a5' in\n> submodule path 'repo_a'\n> \n> Ok, so a bit of googling and I found this:\n> http://stackoverflow.com/questions/13425298/git-submodule-update-fatal-error-reference-is-not-a-tree\n> Ok, so update the repo that contains the submodules every time you\n> push from a sub repo? How / where do I create a hook to do this?\n\nYou've got it switched.  You *did* push the superproject, but forgot\nto push the new submodule commits that it references.  An easy way to\navoid this problem is to always push the superproject using:\n\n  $ git push --recurse-submodules=on-demand …\n\nIf you no longer have access to the submodule repositories that\nweren't pushed, you'll have to roll back the superproject so it\nreferences submodule commits that were pushed.  The easiest way to do\nthis is probably to just cd into the submodule directory and checkout\nan appropriate commit (e.g. origin/master):\n\n  $ cd repo_a\n  $ git fetch origin\n  $ git checkout origin/master\n\nThat will put you on a detached HEAD, so you might want to replace the\ncheckout with:\n\n  $ git checkout -B master origin/master\n\nor some such to get a local branch.\n\nThen cd back into the superproject and commit the submodule\n(referencing the current submodule commit):\n\n  $ cd ..\n  $ git commit -m 'repo_a: Roll back to last public commit' repo_a\n\nWhen you push that commit, don't forget to push everything ;)\n\n  $ git push --recurse-submodules=on-demand\n\nCheers,\nTrevor\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"}]}