Eliezer Wohl
Eliezer Wohl

Reputation: 607

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.

Upvotes: 22

Views: 12697

Answers (3)

Freddy
Freddy

Reputation: 2382

You can simple do,

git checkout master

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

Upvotes: 1

11thdimension
11thdimension

Reputation: 10653

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

Upvotes: 2

Stefan Kendall
Stefan Kendall

Reputation: 67892

git branch master origin/master

Upvotes: 48

Related Questions