Difference between git commit and git push

Version control is an integral part of IT development. It is very essential thing in Software development lifecycle which helps you to manage your code repositories for Development and different environments. Git is an distributed version control system.

Now a days, Most of the projects are using Git as one of the Subversion control tool. While working with Git, As a beginner first question comes to my mind is what’s the different between Git fetch and Git pull. Main purpose for both is to download the latest code/source files from remote repositories.

Whenever you work with Git, Whenever you checkout any branch it is replica/snapshot version of the actual remote code repositories. and it is very important that you need to work on the latest code and you check-in the latest code to avoid wasting your time to merge code manually.

git commit

Git commit “records changes to the local repository“. that means whenever you do git stash followed by git commit, it will store your changes to the local repository in your system. It won’t changes anything into remote repository.

git commit -m

However, for adding new file into Staging environment you need to stash new file using git add command.

git push

Git push “updates remote references along with associated objects”. This will push your changes to the remote repository so that anyone can see your changes and it’s available for everyone in the distribution way of development.

git push -u origin

We can conclude from above example that we can push changes to local repository using git commit while you can push those changes to remote repository using git push.

For Git cheatsheet, You can refer this.

Join Discussion

This site uses Akismet to reduce spam. Learn how your comment data is processed.