I know there are 2 ways to create a branch. Remotely using a gui version control like GitHub or locally using git bash. When I create a new branch remotely and fetch the changes using git bash, the new branch is listed in my config file in the .git directory.
However, when I create a branch locally using git checkout -b <branchname>
it is not listed in the config, but when I check its creation using git branch -l
it is listed as it should be. Why is this? It is only after I specify the remote counterpart for the local branch that it is listed in the config.
I have created a new branch using git checkout -b <branchname>
. I expect at least the [branch "branchname"]
entry to appear in the config file, but nothing appears.
There is a known feature of git checkout [name]
, when [name]
does not exist yet locally but exists on a remote:
-- from
git help checkout
:If
<branch>
is not found but there does exist a tracking branch in exactly one remote (call it<remote>
) with a matching name and--no-guess
is not specified, treat as equivalent to$ git checkout -b <branch> --track <remote>/<branch>
The added section in .git/config
comes from the --track <remote>/<branch>
part, not from the fact that you create a local branch.