Git: add vs push vs commit

后端 未结 8 782
自闭症患者
自闭症患者 2020-12-04 05:04

What is the difference between git add, push and commit?

Just a little confused coming from SVN, where \"update\" will \'add\'

8条回答
  •  孤城傲影
    2020-12-04 05:25

    • git add adds files to the Git index, which is a staging area for objects prepared to be commited.
    • git commit commits the files in the index to the repository, git commit -a is a shortcut to add all the modified tracked files to the index first.
    • git push sends all the pending changes to the remote repository to which your branch is mapped (eg. on GitHub).

    In order to understand Git you would need to invest more effort than just glancing over the documentation, but it's definitely worth it. Just don't try to map Git commands directly to Subversion, as most of them don't have a direct counterpart.

提交回复
热议问题