What are the differences between “git commit” and “git push”?

What are the differences between “git commit” and “git push”?

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?

Solutions/Answers:

Solution 1:

Basically git commitrecords changes to the repository” while git pushupdates remote refs along with associated objects“. So the first one is used in connection with your local repository, while the latter one is used to interact with a remote repository.

Here is a nice picture from Oliver Steele, that explains the git model and the commands:

Git data transport commands

Read more about git push and git pull on GitReady.com (the article I referred to first)

Solution 2:

commit: adding changes to the local repository

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

Solution 3:

Well, basically git commit puts your changes into your local repo, while git push sends your changes to the remote location.

Solution 4:

Since git is a distributed version control system, the difference is that commit will commit changes to your local repository, whereas push will push changes up to a remote repo.

Solution 5:

git push is used to add commits you have done on the local repository to a remote one – together with git pull, it allows people to collaborate.

Solution 6:

Commit: Snapshot|Changeset|History record|Version|’Save-as’ of a repository. Git repository = series (tree) of commits.

Local repository: repository on your machine.

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

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

Related:  Hello world!

git push, git pull: Sync a local repository with its associated remote repository. push – apply changes from local into remote, pull – apply changes from remote into local.

References