2

So I have just learned that git pull does several things

  1. fetch to update local remote mirror
  2. merge to merge local branch with updated local remote mirror

But what about push does it do several things under the hood similar to pull ?

2 Answers 2

7

Not really.

In a very technical sense, yes, it does multiple things, but unlike pull (where you might reasonably do fetch and merge as two different actions) all of the stuff that push does is generally always done together:

  1. Pack up the set of commits that isn't on the remote host
  2. Send the packed commits to the remote host
  3. Update the remote ref to point at the commit you pushed to it

Doing #3 wouldn't really make sense without also doing #1 and #2 - and doing #1 and #2 wouldn't really do anything without also doing #3.

push never merges - you either overwrite the remote ref or your push fails.

Sign up to request clarification or add additional context in comments.

2 Comments

It effectively does a git merge --ff-only to update the remote reference.
@Zeeker which isn't really a merge (just a branch --contains check).
0

You can reed the official documentation of git at http://git-scm.com/docs/git-push
There you can see, that

git push

does not do several things step by step

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.