For newbies, What do Git Pull, Push, and Commit do?

steve July 3, 2019

For those not familiar with Git commands, the following web page may be very useful. It includes a discussion of:
The major difference between Git and any other VCS (version control system) .

https://git-scm.com/book/en/v1/Getting-Started-Git-Basics
Here are some highlights from the above page:

"Now, pay attention. This is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in: committed, modified, and staged. Committed means that the data is safely stored in your local staged. Committed means that the data is safely stored in your local database (repository). Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit snapshot."


This means that Commit does not modify the remote repository by itself, only when you do a Push at the same time or at a later time as a Commit.
If you thought that Commit makes your changes visible to other users of the remote repository, that is wrong.  Push is what accomplishes that.  Pull is what merges other users' changes into the files you have modified (but not pushed) and what copies the changes others have made to files you have not modified.

The following web page explains more about what commit really does.

https://git-scm.com/book/en/v1/Git-Basics-Recording-Changes-to-the-Repository

The above web page is part of a useful chapter that is introduced here:
https://git-scm.com/book/en/v1/Git-Basics

The following web page explains what push and pull really do.
https://git-scm.com/book/en/v1/Git-Basics-Working-with-Remotes

I found that when someone had updated the remote repository and I had modified files in my local repository, it helped if I used Sourcetree to first do a commit without a push, then a simple pull (using the defaults or checking 'Commit merged changes immediately).  Then I could do a commit if necessary, and then a Push.  Every other sequence I tried in Sourcetree gave me an error.

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events