gitgit-pushgit-remotegit-config

What is the difference between push.default "matching" and "simple"


I have been using Git for a while now, but I have never had to set up a new remote repo myself, and I have been curious to do so. I have been reading tutorials and I am confused on how to get git push to work.

If I simply use git push, it asks me to see up a "default branch" to point to. What is the difference between these two options it supplies me with?

git config --global push.default matching
git config --global push.default simple

The matching option just pushes whatever branches I have on my local repo, and if they don't match I have to then manually tell it to push whatever new local branches I have, correct? Is this best practice to use or is simple best?


Solution

  • git push can push all branches or a single one dependent on this configuration:

    Push all branches

    git config --global push.default matching
    

    It will push all the branches to the remote branch and would merge them. If you don't want to push all branches, you can push the current branch if you fully specify its name, but this is much is not different from default.

    Push only the current branch if its named upstream is identical

    git config --global push.default simple
    

    So, it's better, in my opinion, to use this option and push your code branch by branch. It's better to push branches manually and individually.