tags:

views:

366

answers:

5

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? Thanks for reading!

+4  A: 

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, that explains the git model and the commands.

tanascius
That's a good graphic making it easy to understand.
GreenMatt
Here is the original source: http://osteele.com/archives/2008/05/my-git-workflow with another picture of a git workflow
tanascius
Ah that makes sense, thanks a lot! A quick follow up if I may, in the tute I'm doing, the author makes it seem like setting up GitHub is totally optional, but then starts using git push. Does using push send to GitHub, if that's what you've setup?
ben
@ben: Yes, when github is your remote repository, a `push` will sent to github - see here for making github the remote repository: http://github.com/guides/setting-up-a-remote-repository-using-github-and-osx
tanascius
@ben github is but one solution to host your public, "on-the-cloud", repository for `git push` to work with. In reality, the destination of `git push` can be *any* git repository. It can be on your own local hard drive in another directory (`git remote add clone ~/proj/clone.git; git push clone master` or `git push ~/proj/clone.git master`, for example), or a git repository that your *own* host serves.
Santa
+2  A: 

"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.

Michael Borgwardt
+3  A: 

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

Hippo
+1  A: 

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.

Justin Ethier
+1  A: 

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

markovuksanovic