1

I've read in a number of places that simply executing git fetch will default to fetching origin, and that if you have no remote called origin, the fetch will fail with

fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched. 

Is it possible to default git to fetch something other than origin? I prefer to name my remotes a little more descriptively (like gitlab or bitbucket).

1 Answer 1

4

origin is just the default name for the default remote, just like master is the default name for the default branch. But none of that is set in stone, and you can easily change it. It’s perfectly fine to work with a repository that has neither an origin remote nor a master branch.

git fetch will default to using origin if no remote name is specified and if there’s no upstream remote configured for the current branch.

So in order to have git fetch fetch from a different remote, you need to set up your branch to track the remote’s remote branch, for example by doing the following:

git branch --set-upstream-to=github/master 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.