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.

  • New Git repository has no “master” branch
  • src refspec master does not match any when pushing commits in git
  • How to use tags for versioning in git gui
  • Is there an internal alternative to to run behind a firewall?
  • refname is ambiguous and pull failing
  • How to remove files from git staging area?
  • Entering 'rails'
    From git://
     * branch            master     -> FETCH_HEAD
    Already up-to-date.
    Entering 'roo'
    From git://
     * 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.

  • source tree how to discard an un pushed commit and go step back
  • os x server and remote git repos
  • Git octopus merge order of multiple branches
  • Using GIT_SSH_COMMAND in Git for Windows
  • Decoding Git index file using C#
  • How to disconnect git for a project in intellij?
  • 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.