New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #528

wants to merge 1 commit into
base: gh-pages


None yet
3 participants

kyclark commented May 16, 2018

Sorry I forgot to make a commit message (esp when talking about commit messages -- doh!), but it's factually incorrect to say that one must "git add" a file in order for a commit to be accepted. One need only "add" a file once, then "commit" multiple times. The reason no commits were recorded is that the file to commit was not indicated to git. I have corrected the example and also noted the "-a" flag that says to apply the commit message to "all" files that changed.


This comment has been minimized.


iglpdc commented May 16, 2018

Thanks, @kyclark ! I'm a bit confused by your changes. I think it's correct to say that changes in a file should be added (or staged) before being commited (see docs for git-commit and git-add).

The typical workflow (and the one we recommend in the lesson) is using git add to collect all the changes in several files followed by git commit with no file arguments. I think other alternatives, such as git commit -a should be used only in specific cases and once one has some experience with Git.

As you mentioned, Git supports the "Subversion-way" of commiting files in one step with git commit -- file1 file2..., but I think it's very error-prone (it's easy to forget a file or add unwanted changes) and should not be recommended to a new user.

@iglpdc iglpdc self-assigned this May 16, 2018


This comment has been minimized.

kyclark commented May 16, 2018

OK, I just read the official "git-add" docs, and it agrees with your workflow. In my many years of using Git, I've never used "add" except to specifically start tracking a file, and I always "commit" specific file(s) or use "-a" if I've made a batch of changes around the same idea.


This comment has been minimized.

mzedevworks commented Jul 21, 2018

I have also been using "git commit -a" for many years but usually I have realized that it brings up two issues and agree that it mustn't be taught to novices.

  • Usually the commit message is not very specific as its one commit message for a lot of files and becomes misleading for others when they go through the commit messages to find out what was changed.
  • The other biggest problem I found with it is having to commit changes that are not ready to be committed as this will commit everything. This gets reduced by doing "git add" first as it will allow you to first stage only the files you want to go with this commit you are preparing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment