15

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?

utahwithak
  • 6,235
  • 2
  • 40
  • 62
  • You may find the answers to the following question of interest: http://stackoverflow.com/questions/3834627/disable-git-staging-area – Greg Hewgill Sep 23 '11 at 04:21

3 Answers3

27

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.

Dave
  • 11,499
  • 5
  • 34
  • 46
  • 1
    will `git commit -a` only commit the changed files or will it also include the untracked files? If it is the former, how can I have it automatically commit untracked files as well? – Mark Kramer Mar 20 '17 at 03:39
  • It seems odd that the default behavior is to consider use cases when you don't want to track everything. In most cases, wouldn't you want to track everything? – Magnus Lind Oxlund Jul 30 '23 at 04:03
2

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.

manojlds
  • 290,304
  • 63
  • 469
  • 417
2

In case of git you don't need to add files. Git keeps a track of all the files that have been added by you till till now. You only need to add if you are adding a new file that is not there in your git remote repo.

For files that have been modified, you can use git commit -am "message"

git commit -am "message" will automatically commit all the changed files.

After a commit you need to push the data to remote using git push command.

Hope this resolves your problem!!

Piyuesh Kumar
  • 436
  • 5
  • 21