After cloning a repo checkout to "X" branch does nothing and it is a valid branch, if i switch to any other branch from master..and then switch to "X" it works but not directly from master.
After running git checkout X, nothing happens and no error.
When we run git branch it still shows master branch.
Need help on this.
I had the same issue and the cause was that i had a file that had the same name than my branch on the root of my repo.
So a "git checkout X" command was checkouting the file instead of switching to the branch X.
Hi @sudhakar yala,
Have you been able to resolve this? If yes, it would be awesome if you could share with us what was happening and how this has been addressed.
Cheers,
Caterina - Atlassian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the community!
As you mentioned in your description, you are in Master branch and running the git checkout X. so here X is nothing but master or any other branch?
"checkout" is the act of switching between different versions of a target entity like a branch, commit, files...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Yogesh Mude, Thanks for the reply.
Yes X is another branch not master.
Yes i am unable to switch to X branch from master, however after switching to any other branch and switching back to X branch works fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It should switch from any branch to any.
Is this X branch is created from bitbucket using create branch or git?
If this X branch is created from Bitbucket server then can you please try to create a new branch using below command from git and try to switch in between.
git checkout -b <branch_name>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It works fine when we use git checkout -b <branch_name> and able to switch as well, but we do not want to create a new branch, X is existing valid branch, to which we are trying to switch. And we are unable to do so.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
[root@ululinxxx devlabsctl]# git branch -a
develop
* eof-fix
master
remotes/origin/bat-env
remotes/origin/X
You can see the last line, we are trying to switch to that.
for reference please see below lines.
[root@ululinxxx devlabsctl]# git branch
* master
[root@ululin033 devlabsctl]# git checkout ci
[root@ululin033 devlabsctl]# git branch
* master
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As you are using [root@ululin033 devlabsctl]# git checkout ci...but this ci is not listed in branch list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry the last line remotes/origin/X=ci, I just replaced it with X
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its Ok, X branch is remote branch correct?
can you please use the below command and check.
git checkout --track origin/X
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok That's intresting it worked.
[root@ululin033 devlabsctl]# git branch
* master
[root@ululin033 devlabsctl]# git checkout ci
[root@ululin033 devlabsctl]# git branch
* master
[root@ululin033 devlabsctl]# git checkout ci
[root@ululin033 devlabsctl]# git branch
* master
[root@ululin033 devlabsctl]# git checkout --track origin/ci
Branch ci set up to track remote branch ci from origin.
Switched to a new branch 'ci'
[root@ululin033 devlabsctl]# git branch
* ci
master
But now the question is why it did not work the way it should have been and is there any difference if we use git checkout --track origin/ci, instead of git checkout ci.
Will all the commit history be intact.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am glad that I helped you to solve your problem.
For more details please have a look at the below article.
If you feel this answer is helped you to solve your issue then please don't hesitate to accept this answer, It will help others those who will face the same issue in future.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Yogesh Mude, Thanks for the reply.
[root@ululin033 devlabsctl]# git checkout --track origin/ci
Branch ci set up to track remote branch ci from origin.
Switched to a new branch 'ci'
We do not want new branch to be created, we already have a remote branch ci, to which it needs to checkout, inspite of that its creating new branch.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please check the git checkout local documentation using below command..
man git-checkout
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.