JumpstartLab/curriculum — pull request #514 by geopet (2013-04-18 05:28:56+00:00)
Title: Edit git commit command

Using `$ git commit -a` causes a fatal error. This commit changes the
process to add all changed, deleted and untracked files with the `-A` flag
and then uses the `-m` flag to commit with a message.

The alternative to two separate commands on two different lines could be addressed by doing something like `$ git add -A && git commit -m '...'` but I think that the two separate lines make this more understandable. Since this is a teaching document, I think making this more understandable instead of more terse is desirable.

----

Here's what's happening with the current set up and why I came to the solution that I did.

Before running any git commands this is what the local repo looks like at the end of section I1:

```bash
# On branch form-based
# Changes not staged for commit:
# (use "git add/rm ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: app/controllers/articles_controller.rb
# modified: app/models/article.rb
# modified: app/views/articles/show.html.erb
# modified: app/views/layouts/application.html.erb
# modified: config/routes.rb
# deleted: public/index.html
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# app/views/articles/_form.html.erb
# app/views/articles/edit.html.erb
# app/views/articles/new.html.erb
no changes added to commit (use "git add" and/or "git commit -a")
```

If we run `$ git commit -a "..."` we get the error:

```bash
$ git commit -a 'form-based workflow feature complete'
fatal: Paths with -a does not make sense.
```

If we run `$ git commit -am "..."` and then look at the status of the repo we see that haven't included the untracked files we created in I1:

```bash
$ git commit -am 'form-based workflow feature complete'
[form-based bab9623] form-based workflow feature complete
6 files changed, 36 insertions(+), 243 deletions(-)
delete mode 100644 public/index.html

$ git status
# On branch form-based
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# app/views/articles/_form.html.erb
# app/views/articles/edit.html.erb
# app/views/articles/new.html.erb
nothing added to commit but untracked files present (use "git add" to track)
```

The solution is to run `$ git add -A` and then `$ git commit -m "..."` as we can see:

```bash
$ git add -A

$ git status
# On branch form-based
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# modified: app/controllers/articles_controller.rb
# modified: app/models/article.rb
# new file: app/views/articles/_form.html.erb
# new file: app/views/articles/edit.html.erb
# new file: app/views/articles/new.html.erb
# modified: app/views/articles/show.html.erb
# modified: app/views/layouts/application.html.erb
# modified: config/routes.rb
# deleted: public/index.html

$ git commit -m 'form-based workflow feature complete'
[form-based 3593cef] form-based workflow feature complete
9 files changed, 60 insertions(+), 243 deletions(-)
create mode 100644 app/views/articles/_form.html.erb
create mode 100644 app/views/articles/edit.html.erb
create mode 100644 app/views/articles/new.html.erb
delete mode 100644 public/index.html
```

Now the repo is as happy as a :fish: in the :ocean: