Hi Terry,

> Natalie wrote:
> > The "-m" in "git commit" is the message parameter, so it bypasses
> > using an editor to fill it in.  The "-a" does the same as "git add .",
> > so you don't need it if you have done "git add ." before.
>
> Ah!  I was mis-remembering it as 'All'

git-commit(1) says -a is --all so your memory's on point.  But ‘all’
does not include new files:

    -a, --all
        Tell the command to automatically stage files that have been
        modified and deleted, but new files you have not told Git about
        are not affected.

Whereas git-add(1) explains ‘git add .’ does include new files:

    <pathspec>...
        Files to add content from.  Fileglobs (e.g. *.c) can be given to
        add all matching files.  Also a leading directory name (e.g. dir
        to add dir/file1 and dir/file2) can be given to update the index
        to match the current state of the directory as a whole
        (e.g. specifying dir will record not just a file dir/file1
        modified in the working tree, a file dir/file2 added to the
        working tree, but also a file dir/file3 removed from the working
        tree).  Note that older versions of Git used to ignore removed
        files; use --no-all option if you want to add modified or new
        files but ignore removed ones.

Example:

    $ >foo
    $ git add .
    $ git status -s
    A  foo
    $
    $ >bar
    $ git status -s
    A  foo
    ?? bar
    $
    $ git commit -am foo-only
    [master (root-commit) 2e31661] foo-only
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 foo
    $ git status -s
    ?? bar
    $
    $ git add .
    $ git status -s
    A  bar
    $
    $ git commit -am bar-too
    [master fbdedab] bar-too
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 bar
    $
    $ git status -s
    $

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2026-03-03 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  https://dorset.lug.org.uk
  New thread, don't hijack:  mailto:[email protected]

Reply via email to