Configure git to always fetch only current branch and master

414 Views Asked by At

Is it possible to configure git to, by default, when using git fetch, fetch only the current branch and master from the remote, without explicitly mentioning the current branch name?

I know that I can achieve this exact fetch with this command:

git fetch origin $(git rev-parse --abbrev-ref HEAD) master:master

But I would like to have the same behavior when I run only

git fetch

Is that possible to configure? For instance, by some magic refspec in the .git/config file.

Note that, in the configuration, I don't want to hard code the name of the current branch, and I don't want to use aliases.

0

There are 0 best solutions below