ykaganovich
ykaganovich

Reputation: 14964

How do I find out which remote git branch I checked out?

git checkout origin/some_remote_branch
...
> You are in 'detached HEAD' state....

How do I later find out what I checked out?

Upvotes: 2

Views: 272

Answers (3)

VonC
VonC

Reputation: 1323125

You should rather create a local branch based on the remote branch you want to check out.
Then, a git status would be more helpful (instead of the current "Not currently on any branch")

git checkout -b some_remote_branch origin/some_remote_branch

Otherwise, all you could do is list the branches which includes the commit you are currently at (in a detached HEAD situation):

git branch -r --contains <commit>

(as in "How to list branches that contain a given commit?")

Upvotes: 0

Lucas Trzesniewski
Lucas Trzesniewski

Reputation: 51330

One simple command: git status

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

In the case of a detached head, you'll get this message:

$ git status
HEAD detached at origin/master

Upvotes: 1

Codecraft
Codecraft

Reputation: 8296

try: git status

It should tell you what branch you're on and the state of any changes you've made.

Upvotes: 0

Related Questions