0

We have 2 branches. One is live and the other is admin. We just moved to a paid github account and I was working on live.

After git push, when i type "git branch", only live shows up. I don't know why. Mistakenly, i typed "git branch admin" instead of "git checkout admin" and I think this created a clone of the live.

I can't access the admin branch anymore! What should I do?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
user3362364
  • 441
  • 11
  • 25
  • You most likely want to delete the `admin` branch you created by mistake (run `git branch -d admin` for that), then fetch the `admin` branch from the remote (run `git fetch`), then check out the remote-tracking branch as a local branch (run `git checkout admin`). – jub0bs Nov 30 '15 at 18:50
  • Could you kindly post this as answer? It's working now. Thank you so much. – user3362364 Nov 30 '15 at 19:16

1 Answers1

1

If a branch admin already existed, then if you had typed

git branch admin

You should get the error:

fatal: A branch named 'admin' already exists.

This suggests that perhaps you never pulled the branch to your machine, or deleted it in some other way. Why not just pull the branch again from GitHub?

git fetch origin admin    
git checkout -b admin origin/admin
Micah Smith
  • 4,203
  • 22
  • 28
  • I got this when I do `fetch origin admininterface` * branch admininterface -> FETCH_HEAD. However, when i do the checkout, it says, "A branch named 'admin' already exists." When i enter git branch, `Already on 'admin'`. The codes are those of `live`. What did I missed? – user3362364 Nov 30 '15 at 19:13
  • 1
    Thanks. I deleted the `admin` and then use `git checkout admin`. This pulled the correct one. Thank You :) – user3362364 Nov 30 '15 at 19:16