Given
$localBranch = git branch --show-current
$remote = git config branch.$localBranch.remote
$remoteBranch = git config branch.$localBranch.merge
$remoteTrackingBranch = $remote/$remoteBranch
when I do git push
, it seems to implicitly do git push <source>:<target>
where
<source> := $localBranch
, and<target> := $remote $remoteBranch
This updates both the remote-tracking branch and the remote branch to match the local branch.
I would like for git pull
to have a similar behavior. git pull
does git fetch
followed by git merge
. So, I would like for git fetch
(whether called explicitly, or via git pull
) to parallel git push
, i.e. I would like for git fetch
to implicitly do git fetch <source>:<target>
where
<source> := $remote $remoteBranch
, and<target> := $localBranch
This would updates both the remote-tracking branch to match the remote branch.
If doing git pull
, the subsequent git merge
would update the local branch to match the remote-tracking branch and remote branch.
Is there a way to induce this behavior? If so how? Maybe by editing the config file (git config --edit
). Would I make an alias for fetch
?
Currently, git fetch
fetches many remote branches* to the local repo, which I do not want.
*Does this via git config -get-all remote.origin.fetch
which looks like
...
+refs/heads/dev/jv/*:refs/remotes/origin/dev/jv/*
+refs/heads/feature/*:refs/remotes/origin/feature/*
+refs/heads/hotfix/*:refs/remotes/origin/hotfix/*
refs/heads/master:refs/remotes/origin/master
4