Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 324
Black Avatar asked Mar 07 '19 14:03

Black


People also ask

What is default remote branch git?

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).

How do I change git remote settings?

In order to change the URL of a Git remote, you have to use the “git remote set-url” command and specify the name of the remote as well as the new remote URL to be changed. For example, let's say that you want to change the URL of your Git origin remote.


1 Answers

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.

like image 184
axiac Avatar answered Oct 03 '22 05:10

axiac