Danijel
Danijel

Reputation: 8598

Finding the value of git-config `push.default` on my system?

From the Git Config documentation:

push.default
    Defines the action git push should take if no refspec is explicitly given. 

How do I find out the value of push.defaulton my system?

I just did git push intending to push only the current branch, however I ended up pushing other branches too.

Upvotes: 3

Views: 1131

Answers (3)

Code_Ninja
Code_Ninja

Reputation: 1877

You have to first fetch the list of all the global config variables initialised on your system. You get them by using the following command:

git config --list

After this a list of all the variables will be displayed. Find push.default in it. If there is a variable by that name, then the following command as mentioned by @RomainValeri will get you the desired result:

git config --system --get push.default

If you cannot find the above variable but want to set it, then you can set it by using the following command:

git config --system push.default "Your value here"

Upvotes: 0

ElpieKay
ElpieKay

Reputation: 30878

git config push.default prints the value if it's set. If --show-origin is used, it also prints where the value is defined. If the value is empty, it's not set at all. Besides push.default, branch.<name>.merge with branch.<name>.remote also has effect on the push behaviour. <name> is the name of the current branch.

Upvotes: 0

Romain Valeri
Romain Valeri

Reputation: 21998

With git config --system --get push.default.

If you have no output, it means that git has no config entry at this level.

It might, however, have it recorded at another level, like --global or --local

To be sure, don't ask for a specific level by just omitting the --system flag.

In the past, the default value for push.default setting at git install was matching, which does push every branch to its matching counterpart. It changed at some point to now simple, which just pushes the current branch.

Upvotes: 2

Related Questions