Subin
Subin

Reputation: 386

Unable to see gh-pages branch in git branch?

In git bash, when I type git branch, it only displays the master branch. But I have created gh-pages branch in GitHub.

Why this happening? How do I move my code from other branches to gh-pages rather than drag and drop in GitHub?

Upvotes: 2

Views: 4711

Answers (3)

iclman
iclman

Reputation: 1436

The command "git branch" lists the local branches. The command "git branch --all" lists all the branches including the remote branches.

In your case, if you have created the branch directly on the Github.com site, you will not see the branch with the command "git branch" if you have not sync'd your local repository with the server.

You need first to perform a "git fetch" or a "git pull" so that your clone is up-to-date with the server. You should then see the branch as a remote branch "remotes/origin/gh-pages" with the command "git branch --all".

In order to see the branch "gh-pages" with the command "git branch, you need to create it locally in your clone. You can do so with the command (provided you have done the fetch beforehand)

$ git checkout gh-pages

It will create locally the branch gh-pages and set it to track the remote branch remote/origin/gh-pages

Upvotes: 2

Shriram
Shriram

Reputation: 328

You have to pull the new branch from GitHub to your local machine.

Say,If you create a gh-pages branch on GitHub then you have to pull it to your desktop using

git pull origin gh-pages

in git bash.

To copy a file from a different branch to the current branch, you may use

git checkout branch-having-the-file file.exe

and then git add .

Upvotes: 0

OznOg
OznOg

Reputation: 4732

you only see you local branches, to see all branches (an especally remotes ones) yo need to do:

git branch --all

Upvotes: 0

Related Questions