I think this command below, will checkout a remote branch name ‘branch_name’ and create a local branch for me called ‘branch_name’.
'git checkout -b branch_name "`git remote`"/branch_name'
My question is
-
how can I run this despite I already has a branch name ‘branch_name’, can I ask git it checkout to branch_name even (if that branch already exist)?
-
when I do ‘git branch -a’, I don’t see a branch ‘remote/branch_name’, I only see a branch ‘remotes/ser-git/branch_name’. How can git find the right remove branch from ‘git remtoe’/branch_name?
Use
-Boption instead of-bgit resolves reference name in the following order:
$GIT_DIR/<name>exists, that is what you mean (this is usually useful only forHEAD,FETCH_HEAD,ORIG_HEAD,MERGE_HEADandCHERRY_PICK_HEAD);refs/<name>if it exists;refs/tags/<refname>if it exists;refs/heads/<name>if it exists;refs/remotes/<name>if it exists; <- this is your caserefs/remotes/<name>/HEADif it exists.It means that if you have local branch
ser-git/branch_name, it will be preferred by git instead of remote branch.