How to update a git repo containing a submodule?

After some time I wanted to update my git repo, and then something went wrong. What is the proper way out of this situation?

mblsha@siruba:~/src/psi/ $ git status
iris: needs merge
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#   modified:   src/common.cpp
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   unmerged:   iris
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
mblsha@siruba:~/src/psi/ $ git submodule status
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master)
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master)
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master)
mblsha@siruba:~/src/psi/ $ cd iris 
mblsha@siruba:~/src/psi/iris/ $ cat .git/HEAD 

  • Not currently on any branch + git commit + checkout when not in any branch. Did i loose my changes?
  • Homebrew: insufficient permission for adding an object to repository database .git/objects
  • How can I use gitstats to find out how many SLOC a Git repo has in total and per commiter?
  • Undoing temporary changes with Git
  • Cannot push to GitHub
  • Git push failed, “Non-fast forward updates were rejected”
  • Git on Cygwin: Fails to add the host to the list of known hosts
  • How to revert Git repository to a previous commit?
  • git smudge/clean filter between branches
  • Source Tree SSH Public Key Denied
  • Calculating total lines added/deleted after a merge?
  • Xcode tree conflicts on merge
  • 2 Solutions collect form web for “How to update a git repo containing a submodule?”

    When it comes to git submodules, almost any problem you encounter can be solved by:

    1. deleting the submodule (rm -r iris)
    2. recreating it again (git submodule update)

    Obviously if you have made local changes to your submodule this will DELETE them PERMANENTLY, so if you have local changes make sure you have pushed them first.

    I posted a similar question here on stackoverflow and ended up answering it myself, but I found that using git reset HEAD iris worked for my issue with submodule conflicts.

    Git Baby is a git and github fan, let's start git clone.