I spent the last 6 hours trying to initialise my repository on vs code and changing the master branch to main, here is how I finally did it.
I created an empty file and opened it on vs code, like I should. Then I went to github and created a repository after which I copied the url.
By default if you initialise a repository on vs code it is set to the master branch which I didn’t want. So I clicked on View (at the nav bar) and clicked on command template, it brought out a search bar where I wrote "Git: Add remote" (it auto fills) and clicked on it.
It asked for the url of my repository which I provided and also asked for a name which I gave it (anything goes) after wards i clicked enter and in command template I typed "Git: Checkout to" which brought out the master branch and the url I provided below, I clicked on the Url and master branched icon at the right bottom of vs code changed to main. I then proceed to commit and push to git hub which updated my main branch without creating a master branch or promoting any errors.
I hope this helps whoever needs it, and I’ll advise you add your Repository url and changing the master to main before commiting, other wise it updates in master and I don't know how to change it afterwards.
I hope this helps someone and I still don’t know why it’s not set to main by default.
Top comments (0)