简体   繁体   中英

Deleted local master branch

I was sloppy and was deleting a whole bunch of local branchs, instead of doing them one by one after each one was done, and I accidentally deleted my local master branch on git. The project is still up at github. So how do I resolve this issue? If it helps I'm using terminal on a mac.

git branch master origin/master

Master branch is not a special branch, it can easily be created just as any other branch.

git branch master ## creating master branch
git checkout master  ## switching to master branch
git branch -u origin/master ## setting up remote tracking branch

or

git branch master ## creating master branch
git branch -u origin/master master ## setting up remote tracking without switching
git checkout master ## switching out to master

or all in one

git checkout -b master origin/master ## create, set up tracking, switch

You can simple do,

git checkout master

Git will pull master branch if you don't have it in local.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM