开发者

Automatic Staging with 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 开发者_JS百科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?


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.


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.


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!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜