I\'m a bit new to git, and I fail to understand why git commit -a
only stages changed and deleted files but not new files.
Can anyone explain why is it
For Future sake you can stick with this solution from Ian Clelland,
git add -A && git commit -m "Your Message"
Since it won't be too visible from comment https://stackoverflow.com/a/2419270/5836034
I suggest another solution: using git commit --interactive -m "your commit message"
will show you this menu
*** Commands ***
1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked
5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp
allowing you to check status, add untracked files and so on using simple keystrokes.
Git is about tracking changes. It relies on you to tell it which files are important enough to track. You can achieve the desired affect like so:
git add . ;git commit -a
Make sure your .gitignore
file is updated.
Kelly is correct but I think another factor is that so many people expect that behavior because CVS, Subversion, and most other tools do it that way.
If Git committed new files, you might notice that you had committed .o
files long ago and even worse they might harm the build.
I suspect the answer is simple (but I doubt I'll be popular for saying it!) -- there is likely no deliberate "why" to this, other than it's how it fell out when the developers implemented it. The priority of the Git project has never been on ease-of-use or user-friendliness.