1

When I roll back my git working directory to a particular commit, the submodule shows as "modified." The submodule is checked in and has no modified files, but it's at different commit than it needs to be. How can I find out the name/hash of the correct commit?

Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421
  • interesting, but not a dupe at all: http://stackoverflow.com/questions/8762513/auto-committing-git-submodule-hash-in-super-project – Dan Rosenstark Apr 09 '13 at 00:02

1 Answers1

2

If what you're looking to do is get your submodules to also rollback to their appropriate commits, then try:

git submodule update --recursive

This will update all of your submodules to the commit they should be sitting at (referencing the meta data your parent repo has stored with each commit about what commits its submodules should be at).

redhotvengeance
  • 27,446
  • 10
  • 49
  • 54
  • That's awesome, thank you. Now my submodule is on the right commit, but not the right branch. I can find the branch using `git branch --contains HEAD` but... is there some magic git command that will move the submodule to the right **branch**? Sorry to be greedy here... – Dan Rosenstark Apr 09 '13 at 01:01
  • Okay, thanks, I've moved that to a question here: http://stackoverflow.com/questions/15891704/git-find-out-which-branch-contains-a-commit-and-check-it-out but I'm pretty sure I'll need to get my scripting on. – Dan Rosenstark Apr 09 '13 at 01:15
  • @Yar Was about to post an update, but instead just answered your new question :) – redhotvengeance Apr 09 '13 at 01:21
  • Glad to set it up ;) Thank you for your help, this stuff is awesome. – Dan Rosenstark Apr 09 '13 at 04:11