Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 651
ben Avatar asked Apr 30 '10 14:04

ben


People also ask

What is the difference between a commit and a push?

Commit - committing is the process which records changes in the repository. Think of it as a snapshot of the current status of the project. Commits are done locally. Push - pushing sends the recent commit history from your local repository up to GitHub.

Does git commit also push?

The git push command allows you to send (or push) the commits from your local branch in your local Git repository to the remote repository. To be able to push to your remote repository, you must ensure that all your changes to the local repository are committed.

Why are commit and push separate?

Commit saves the changes you made only to the local repository but not to the remote repository. Your commits are not automatically synchronized to the remote repository – you have to explicitly push the commits you want to share. When you use the push command, you apply your changes to the upstream repository.


1 Answers

Basically git commit "records changes to the repository" while git push "updates 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)

like image 55
tanascius Avatar answered Oct 11 '22 19:10

tanascius