8

Is -a in git commit -a equivalent to git add . -A?

Assuming i have the following aliases:

 12 alias gita='git add . -A'
 13 alias gits='clear; git status'
 14 alias gitlog='git log --pretty=oneline --abbrev-commit'
 15 alias commit='git commit -a '

 16 alias check='gita;commit'  <--------------------------

When i say check, is there any redundancy happening when i both add -A and commit -a

James Raitsev
  • 92,517
  • 154
  • 335
  • 470

3 Answers3

7

git add -A is NOT equivalent to the -a flag in git commit. git add -u is. It adds changes to tracked files (including rms). git add -A also brings in untracked files.

Since git add -A is superset of git add -u, that is enough and you need not specify the -a in commit as well.

Also, if the path is not given, it is assumed to be ., so the . is superfluous as well.

Starting git 2.0 (mid 2013), you will need to add the path, or git add -A would operate on the full working tree.

See "Difference of “git add -A” and “git add .".

Community
  • 1
  • 1
manojlds
  • 290,304
  • 63
  • 469
  • 417
6

Sort of. git add -A will match against the working tree and the index, adding new files, marking modified files and removing deleted files. git commit -a will stage only files that have been added or modified, but new files will not be added unless already specified in a prior git add

jmkeyes
  • 3,751
  • 17
  • 20
2

Is -a in git commit -a equivalent to git add . -A?

No it is not. git add . -u is.

When i say check, is there any redundancy happening when i both add -A and commit -a

No git commit -a will simply add the remaining files by itself. In this case: none.

TimWolla
  • 31,849
  • 8
  • 63
  • 96