What is the difference between git push -u origin master and git push?


Well, actually, such a simple question … I created a branch, made changes, added files to the tracked ones, committed them, merged them with the master branch, and now I want to send the changes to the server …

How to do it simply

git push


git push -u origin master



The second option clearly shows where you are pushing the commit, the first implicitly.

In most cases, it is enough to indicate the first option, as a last resort you will see (git 2.0 – 2.8) a notification like:

[ak@server abc]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 367 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To abc@asdf:/asdfasddf.git
   b41acb4..b8c32bd  master -> master

I quote :

One of the biggest changes is the behavior of the git push command. Now by default (if no branch is specified) push will only be done to the current branch. Git 1. * by default pushes to all branches that have changed locally. Of course, you can revert to the previous behavior, the push.default option is used for this.

This is a very popular question in English so , it says the same thing:

  • matching means that git push will git push all your local branches to the same ones on the remote server.

  • simple means that git push will only git push current branch to the same branch on the remote server.

Simple is more intuitive, so it is the default and is used if push.default not set.

Scroll to Top