Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic Staging with Git

Tags:

git

I have a git repository and it is doing something I've never seen before and haven't found a solution anywhere. I initialized with git init and added everything with git add * and went on my way now when I try to commit after editing any number of files none are staged for commit so I have to do git add -A which then stages them all for a commit. Is there a way to skip the git add -A step? I have used git with Xcode a lot and never have had to move them from not staged to staged while in the terminal.

Is there a paradigm to the git staging area I am missing? How are you supposed to use it?

like image 403
utahwithak Avatar asked Sep 23 '11 04:09

utahwithak


2 Answers

You do have to add your changes to the commit, but you can just use:

git commit -a

To add your changes AND commit or

git commit -am 'commit message'

Which is how i usually roll.

Manually adding your changes lets you not commit everything if you dont want to, which I'm sure you can tell is useful sometimes.

like image 62
Dave Avatar answered Oct 22 '22 05:10

Dave


Add an alias which will do the add and the commit for you and start using the alias. If you are on Windows, I would have suggested TortoiseGit, which abstracts out the index.

like image 24
manojlds Avatar answered Oct 22 '22 03:10

manojlds