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?
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?
Three things to note:
1)Working Directory ----- folder where our codes file are present
2)Local Repository ------ This is inside our system. When we first time make COMMIT command then this Local Repository is created. in the same place where is our Working directory ,
Checkit ( .git ) file get created.
After that when ever we do commit , this will store the changes we make in the file of Working Directory to local Repository (.git)
3)Remote Repository ----- This is situated outside our system like on servers located any where in the world . like github. When we make PUSH command then codes from our local repository get stored to this Remote Repository
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 commit
is to commit the files that is staged in the local repo.git push
is to fast-forward merge the master branch of local side with the remote master branch. But the merge won't always success. If rejection appears, you have topull
so that you can make a successfulgit push
.git commit
record your changes to the local repository.git push
update the remote repository with your local changes.Just want to add the following points:
Yon can not push until you commit as we use
git push
to push commits made on your local branch to a remote repository.The
git push
command takes two arguments:A remote name, for example,
origin
A branch name, for example,master
For example:
git push <REMOTENAME> <BRANCHNAME>
git commit is nothing but saving our changes officially, for every commit we give commit message, once we are done with commits we can push it to remote to see our change globally
which means we can do numerous commits before we push to remote (we can see the list of commits happened and the messages too) git saves each commit with commit id which is a 40 digit code
and I use git push only when i wanted to see my change in remote (There after i will check whether my code worked in jenkins)