Using Git 1.8.1.1 on Linux. The repository looks as follows:
master
book
The submodule was created as follows:
$ cd /path/to/master
$ git submodule add https://[email protected]/user/repo.git book
The book
submodule is clean:
$ cd /path/to/master/book/
$ git status
# On branch master
nothing to commit, working directory clean
The master, on the other hand, shows there are "new commits" for the book submodule:
$ cd /path/to/master/
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: book (new commits)
#
no changes added to commit (use "git add" and/or "git commit -a")
Git should ignore the submodule directory completely, so that the master is also clean:
$ cd /path/to/master/
$ git status
# On branch master
nothing to commit, working directory clean
Inside the file master/.gitmodules
is the following, as per this answer:
[submodule "book"]
path = book
url = https://[email protected]/user/repo.git
ignore = dirty
Changed master/.gitmodules
to the following, as per this answer:
[submodule "book"]
path = book
url = https://[email protected]/user/repo.git
ignore = untracked
Edited master/.git/config
to the following, as per this answer:
[status]
showUntrackedFiles = no
Added the book directory to the master ignore file:
$ cd /path/to/master/
$ echo book > .gitignore
Added the book directory to the master as follows:
$ cd /path/to/master/
$ rm -rf book
$ git clone https://[email protected]/user/repo.git book
How can the book
submodule be in its own repository directory under the master
repository yet have git ignore the book
submodule? That is, the following should not display:
#
# modified: book (new commits)
#
How to suppress that message when executing git status
in the master repository?
An article about git submodule pitfalls suggests this an inappropriate submodule usage?
Just run:
$ git submodule update
This will revert the submodule the to old commit (specified in parent-repo), without updating the parent-repo with the latest version of the submodule.