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?
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:
Read more about
git push and
git pull on GitReady.com (the article I referred to first)
commit: adding changes to the local repository
push: to transfer the last commit(s) to a remote server
Well, basically git commit puts your changes into your local repo, while git push sends your changes to the remote location.
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.
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.
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.
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.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Ebook Reviews
- PES Matches, Skills & News