Adam Kabbeke
Adam Kabbeke

Reputation: 121

Can't checkout out a remote branch which has been merged on Github

I'm having an odd issue with checking out a remote branch from Github.

Scenario:

I checked out the master branch of a repo from Github. I then created a local branch branch_a and made my changes. I committed the changes to branch_a and pushed them to Github. I created a pull request for branch_a which was approved, and I merged it into master. I didn't delete the branch after the pull request.

Later I cloned a new copy of the repo and tried to checkout branch_a. However, when I try to checkout the branch with git checkout branch_a git fails silently and I am left still on master. The weirdest part is that I can see that the branch exists remotely when I call git branch -a.

To get around this I tried creating a new local branch with the same name as branch_a and made some changes. I pushed these changes and was able to create another pull request for the branch. However, if I clone another copy of the repo and try to check out the repo, I have the same problem where I can't checkout the remote branch_a with the pending changes in the pull request.

Upvotes: 2

Views: 3882

Answers (2)

Sašo Kovačič
Sašo Kovačič

Reputation: 911

This helped me

git fetch --all

git checkout master

git branch new_branch

git checkout new_branch

Upvotes: -2

imPK
imPK

Reputation: 884

If the branch is in the remote origin and you are trying to checkout from this remote

Run git fetch origin branch_a and then checkout git checkout origin/branch_a

Upvotes: 3

Related Questions