0

I've always been doing git commit . -m 'message'

Does git commit -m 'message' only affect the current folder and its sub directories or does it commit everything? And which one is more appropiate?

3
  • Neither is more appropriate, as they mean two completely different things, and each have valid useful scenarios. Did you try reading the manual page for git commit (a.k.a. git help commit)? Commented Dec 17, 2013 at 19:08
  • I have never seen git commit . used often, but rather git commit -a if not git commit Commented Dec 17, 2013 at 20:04
  • i've always thought the . period meant to commit the current directory and everything under it. isnt that the case? Commented Dec 17, 2013 at 20:05

1 Answer 1

1

Adding the '.' is saying stage and commit the changes to files in the current directory that are already in the repository ignoring what has already been staged.

Without the '.' the command will commit only changes that have been staged.

I've not seen the form: git commit . -m 'message' before nor seen it recommended. Though if I'm ever in a rush to commit the changes in the current directory I might give it a go...

In my experience using git add <filenames> to stage changes works well as it allows you to clearly state exactly what you want to stage. Then git commit without the -m is handy as it shows you what you have staged and not and allows you to write the commit message in a proper editor.

The following are some really good freely available resource to learn Git. They explain really much more clearly then I probably can...

http://try.github.io - A quick very well made 15 min tutorial.

http://git-scm.com/book - Excellent clearly presented source for quickly understanding Git.

Or for online help you can always append --help to your command. For example typing the following in you terminal:

git commit --help
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.