DEV Community

Cover image for Main and Master repo in Github - How to solve
Eden Jose
Eden Jose

Posted on • Updated on

Main and Master repo in Github - How to solve

I had a problem before where there are two branches in my github rep:

main
master

Although both should have the same function (as main replaced master), a 'master' branch was instantly created when I try to push my local repo to remote repo.

After some digging, I found a simple solution. Here's what I did:

Eden Jose@EdenJose MINGW64 ~/Desktop/Git/1-KodeKloud (master)
$ git branch -m master main

Eden Jose@EdenJose MINGW64 ~/Desktop/Git/1-KodeKloud (main)
$ git branch
* main

Eden Jose@EdenJose MINGW64 ~/Desktop/Git/1-KodeKloud (main)
$ git push -f --set-upstream origin main
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/joseeden/KodeKloud_Tasks.git
+ 6a54f03...4fe82a2 main -> main (forced update)
Branch 'main' set up to track remote branch 'main' from 'origin'.

Eden Jose@EdenJose MINGW64 ~/Desktop/Git/1-KodeKloud (main)
$ git branch -a
* main
remotes/origin/main
remotes/origin/master

git push origin --delete master
Enter fullscreen mode Exit fullscreen mode

You can check out more about this in the links below:

Discussion (0)