Possible Duplicate:
git add -A, git commit in one command?
If I understand correctly, when new files are added to a directory when using git, I have to call more than one command to make sure that the files are committed:
git add <directory name>
git commit -m 'commit comment'
This doesn't sound right because I know I (and many other people) will forget to call git add <directory name>
and then end up with a project that is missing all the new files that were created. It seems that I should be able to commit the entire directory, including any and all new files, in one command without having to specify in a previous command to add all new files to the commit. How do I do this?
git commit -a
will commit all files known to git:
-a, --all Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected.
If you want to make sure you're committing everything you want to be, you can use git-status
prior to a git-commit
, to see the files that are staged for committing.
git
uses a two-stage process to get changes from the working directory
into the repository
. A catch-all approach like git commit -a
will work, but it will lead to messy, non-atomic commits. I would advocate for smaller, focused commits, rather than using a catch-all approach such as you are searching for.
This doesn't sound right because I know I (and many other people) will forget to call git add...
git-status
is your friend :)
Note: git-add
does not add files to the repository. git commit
commits things from the staging area
the repository
, not from the working area
. This might seem odd at first, but gives much greater flexibility. See another answer for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With