Is there any way I can work on another branch?

I forked only the main branch of a repo from Github. And now I have to work on another branch from that repo but can't find a way to get that branch to my local repo as forking is not an option because it already exists. What options do I have? If you have any solution please help!
8 Replies
Alonso
Alonso6mo ago
Delete the previous fork and do it again forking all the branches
vivekjaiswal4077
will it delete all the PRs I made from that fork
Gad
Gad6mo ago
no need to deleate the fork you have now make sure your current dir is clean then git fetch upstream and git checkout -b newbranch upstream/newbranch replpace newbranch with the name of the brach you have
vivekjaiswal4077
the repo is JSON Schema and I forked it with default settings [only fork main branch] that is why facing this issue, SO I have main branch with me and I want web-release-3 branch in my local repo so I will run the commands from the main and will be like git fetch upstream and git checkout -b web-release-3 upstream and I will get the branch web-release-3 in my local repo. Is that correct ?
Gad
Gad6mo ago
yep its upstream/web-release-3 for the checkout command tho
vivekjaiswal4077
hey Gad thank you so much it worked the only thing is for the checkout command it was giving me error like fatal: 'upstream' is not a commit and a branch 'web-release-3' cannot be created from it so I ran git checkout -b web-release-3 and then it worked
Gad
Gad6mo ago
oh sorry ive never actually ran that command before lol just had it in a giant list of "usefull cmds i might need one day"
vivekjaiswal4077
Oh thats cool!
Want results from more Discord servers?
Add your server