Suggest use of "git add file1 file2" when there is nothing to commit.

If a user modifies files and runs 'git commit' (without the very
useful -a option) and they have not yet updated the index they
are probably coming from another SCM-like tool which would perform
the same as 'git commit -a' in this case.  Showing the user their
current status and a final line of "nothing to commit" is not very
reassuring, as the user might believe that Git did not recognize
their files were modified.

Instead we can suggest as part of the 'nothing to commit' message
that the user invoke 'git add' to add files to their next commit.

Suggested by Andy Parkins' Git 'niggles' list
(<200612132237.10051.andyparkins@gmail.com>).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Shawn O. Pearce
2006-12-15 21:53:09 -05:00
committed by Junio C Hamano
parent e697e4cd1f
commit aeb80c70ec
2 changed files with 7 additions and 6 deletions

View File

@ -520,7 +520,7 @@ then
current="$(git-rev-parse --verify HEAD)"
else
if [ -z "$(git-ls-files)" ]; then
echo >&2 Nothing to commit
echo >&2 'nothing to commit (use "git add file1 file2" to include for commit)'
exit 1
fi
PARENTS=""