0

I have a script that it looping through a number of repos and doing the same command. On one repo, that command is:

git checkout -B master --track remotes/origin/master

That clobbers whatever the local master is with the latest from the remote's default branch.

The problem is that several of theses repos have defaults named something other then master. So far, I have seen main, stable, and develop as the default branch name.

So I want something like

git checkout -B ??? --track remotes/origin/HEAD

But of course git won't let me omit the branch name, and other variants I have tried complain that remotes/origin/HEAD is not a branch name.

How can I write this?

torek
  • 448,244
  • 59
  • 642
  • 775
Matthew Scouten
  • 15,303
  • 9
  • 33
  • 50

0 Answers0