recursively git pull for all of the git submodules simply

My personal repository has some repositories as submodules. And the following command

$ git submodule foreach git pull origin master

was faced with the following result right after entering ruby repository because ruby repository seems that it does not have a master branch and “git pull” stopped.

  • Using repo with goldfish Android kernel
  • Git GUI like HG Workbench in MS Windows
  • Branching and merging with Git
  • Git clone on jenkins master, copy to slave
  • Git history including/interleave submodule commits
  • git rebase develop branch
  • Entering 'rails'
    From git://github.com/rails/rails
     * branch            master     -> FETCH_HEAD
    Already up-to-date.
    Entering 'roo'
    From git://github.com/hmcgowan/roo
     * branch            master     -> FETCH_HEAD
    Already up-to-date.
    Entering 'ruby'
    fatal: Couldn't find remote ref master
    Stopping at 'ruby'; script returned non-zero status.
    

    So my question is what should I do to git pull for all of submodules only by git command? Should I do make a script to this? I hope just ONE command line provided from git will make this.

  • Perforce equivalent for git add patch?
  • How are version control histories stored and calculated?
  • How to use to make a file executable on Openshift server after pushing it via git
  • Keep remote server synced with a Git repo
  • Git: move specific commits to another branch
  • Exclude .svn folders within git
  • 2 Solutions collect form web for “recursively git pull for all of the git submodules simply”

    git submodules are typically in detached-HEAD states, and thus git pull on them can’t figure out what you mean when it comes to the merge phase. If all you are trying to do is get the latest changes into the repository, try git submodule foreach git fetch instead. If you want to get each submodules master updated to its respective origin/master, then you can follow up with git submodule foreach git checkout master; git submodule foreach git merge origin/master.

    Then, of course, you need to decide what version of each submodule you want your main repository to use (I would not recommend blindly going with origin/master all the time – it may be unstable – better to pick a known-good tag or something), check out those versions in the submodules, and follow up with the appropriate git adds and git commit in your main repository.

    Just add || true to your submodule command:

    git submodule foreach 'git commit -m "my commit message" || true'
    
    Git Baby is a git and github fan, let's start git clone.