What are the differences between “git commit” and

2019-01-03 00:12发布

In a Git tutorial I'm going through, git commit is used to store the changes you've made.

What is git push used for then?

15条回答
The star\"
2楼-- · 2019-01-03 01:16

A very crude analogy: if we compare git commit to saving an edited file, then git push would be copying that file to another location.

Please don't take this analogy out of this context -- committing and pushing are nothing like saving an edited file and copying it. That said, it should hold for comparisons sake only.

查看更多
一纸荒年 Trace。
3楼-- · 2019-01-03 01:17

commit: adding changes to the local repository

push: to transfer the last commit(s) to a remote server

查看更多
萌系小妹纸
4楼-- · 2019-01-03 01:17

Commit: {Snapshot | Changeset | History record | Version | 'Save-as'} of a repository. Git repository = series (tree) of commits (plus few extra things).

Local repository: repository on your machine.

Remote repository: repository on a server (eg Github).

git commit: Add a new commit (last commit + staged modifications) to the local repository.

git push, git pull: Sync the local repository with a remote repository. push - apply changes from local into remote, pull - apply changes from remote into local.

查看更多
登录 后发表回答