Pushing / Pulling

Push

What is it?

In git language, pushing is the action to send your local changes to the remote server. Taking the example of only a master branch, you have to keep in mind that there exists a master branch locally (on your computer) and a origin/master branch, which is the master branch of the remote server. And they are indepent, you can think of it as two different branches!

When pushing, git somewhat “synchronizes” your branch master with the remote branch origin/master. Obviously, you can push a different branch than the master (which can be a bad idea or even not allowed). The command is the following

git push origin master

or even just

git push
Pusing is possible only if your branch “more advanced” than remote branch. Sometimes, we first need to pull the changes before pushing ours.

Try!

Pusing is possible only if your branch “more advanced” than remote branch. Sometimes, we first need to pull the changes before pushing ours.

On your computer and in the folder you just clone, type some modification, commit and then push. Check the changes on your webbrowser.

Obviously, you remote server must point to your account!

Pull

What is it?

Pulling the backward operation: applying changes saved on the remote into the local repository ("origin master" is optional):

git pull origin master
There can be conflict which must be resolved but you now know how to do it!

Try!

To try is, we have to change the remote server. We can do it using Gitlab’s interface by chosing a file, modifying it with the inner editor and commit the result in origin/master as shows below. You just have to pull the result after that.

Gitlab editor

Fetch

Fetching is actually part of the pull operation: git download the history of remote branches and does not modify the local branches. Said otherwise,

git pull

is somewhat equivalent to

git fetch
git merge
Précédent
Suivant