Home > Software engineering >  Why I need additional step when cloning if branch name is 'main'
Why I need additional step when cloning if branch name is 'main'

Time:04-14

In the past, when the default branch is 'master' when creating a repository, cloning will auto pull/fetch the files in the branch.

However after I change git global init.defaultBranch to 'main', cloning require additional steps to actually get the file:

git fetch
git pull origin main

If I want to push to the repo, the first time I have to do the following:

git push --set-upstream origin main

Those steps are not required when I was using 'master'. How can I make it automatic again?

PS: I am using gitea as git repo server.

CodePudding user response:

The default branch that is checked out when cloning is determined by the remote repo. But you can change it when cloning too.

To change your default branch in gitea set the DEFAULT_BRANCH parameter.

  • Related