gitbranchgit-pull

How to set default remote in git?


I have multiple remotes in my git repository. If I execute git pull, then it asks for the password of one of my colleagues.

How can I change the remote to black?


Solution

  • There is no default remote, each branch can track a specific branch from a remote repo.

    If you have created the branch using git checkout -b <branch-name> where <branch-name> is the name of a remote branch then the new branch tracks that branch (from whatever remote hosts it).

    If you created the branch locally then used git push --set-upstream <remote-name> <branch-name> then the local branch <branch-name> tracks the remote branch <remote-name>/<branch-name>.

    You can always use git branch --set-upstream-to to change the remote branch that is tracked by the current branch or git branch --unset-upstream to tell it to not track any remote branch.