无法在远程找到远程git分支 - bitbucket
切换到新机器。我需要拉出从旧机器推到遥控器的工作分支。但是我无法通过git命令找到远程分支。我可以在Bitbucket UI中看到分支。
此搜索所有内容并未显示分支
git branch -all
,但是我可以在Grep搜索中看到我的分支机构
git ls-remote | grep "my_branch_name"
From ssh://git@my_org.com:xxxx/xxxx/xxx.git
ed18a***************************113aa4ac HEAD
5b9a1***************************f4aa4f3a refs/heads/feature/mybranch-10XX
704e2***************************2a4586d5 refs/heads/feature/mybranch-5XX
可以将这些分支提供给我的新本地吗?
Switched to a new machine. I need to pull the working branches which was pushed from my old machine to remote. But I am unable to find the remote branches via git command. I could see the branch in BitBucket UI.
This search all is not showing the branches
git branch -all
However I could see my branch in grep search
git ls-remote | grep "my_branch_name"
From ssh://git@my_org.com:xxxx/xxxx/xxx.git
ed18a***************************113aa4ac HEAD
5b9a1***************************f4aa4f3a refs/heads/feature/mybranch-10XX
704e2***************************2a4586d5 refs/heads/feature/mybranch-5XX
Is there anyway to fetch these to my new local ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经有那些分支机构。它们命名为
Origin/feation/myBranch-10xx
和onect> onect/feation/mybranch-5xx
。这些不是分支。相反,它们是分支。如果您想在这些分支上工作,则需要从这些分支机构制作分支。如果这没有道理,那么您正在正确阅读它:git 过度过多的分支一词,以至于失去了所有含义。 是什么意思?
(请参阅“分支”?我们到底 (或至少不是仅分支)。使用以下单词:
origin/main
或onect> onement/fartial/mybranch-10xx
之类的名称;main
或feature/myBranch-10xx
之类的名称;和git将使用名称(分支名称和远程跟踪名称)查找提示的哈希ID(s),然后将使用这些提交来查找早期的提交。使用这些名称(“分支”)找到的一组提交也是“分支”。因此,根据一个人说“分支”的含义,您要么有分支(提交的集合),要么确实有分支(远程跟踪名称),或者您没有分支(您缺少本地分支名称)。
幸运的是,如果您有一个远程跟踪名称,例如
onement/feation/myBranch-10xx
,则要求git切换到(本地)分支名称:而该分支名称不存在,它调用
- 猜测
选项,默认情况下为:git switch
或git Checkout
MENEgit Switch - guess
或git Checkout -guess
。 1 猜测代码拦截了git 的错误如果您使用- no-guess
会给出。 git是关于 的,要说的话是没有本地功能/myBranch-10xx
的效果,但是猜测代码截获了错误。猜测代码通过您的远程跟踪名称扫描,以寻找与之匹配的名称(在这种情况下删除了Origin/
部分之后)。如果找到一个,则它将从远程跟踪名称中创建一个新的(本地)分支名称,识别相同的提交。现在,该提交是在“远程跟踪名称”上的(本地)分支和“”上“”。它也可能在许多其他分支上:在git中,通常在许多分支机构上。无论如何,既然
git switch
或git Checkout
已将猜测代码使用到 create 的分支名称,git可以切换到该分支。现在,您将拥有该特定的 commit 检查,并可以开始进行更改并使用这些更改来进行新提交。1 如果您不希望git猜测,请使用
- no-guess
关闭。在现代版本的GIT版本中,您还可以默认情况下将其作为配置选项禁用。You already have those branches. They're named
origin/feature/mybranch-10XX
andorigin/feature/mybranch-5XX
.Those aren't branches, though. Instead, they're branches. If you want to work on those branches, you'll need to make branches from those branches. If this makes no sense, you're reading it right: Git overuses the word branch so much that it loses all meaning. (See What exactly do we mean by "branch"?)
To make sense out of this, stop calling things "branch" (or at least, not just branch). Use these words:
origin/main
ororigin/feature/mybranch-10XX
;main
orfeature/mybranch-10XX
; andGit will find the hash ID(s) of commit(s) using the names—the branch names and the remote-tracking names—and will then use those commits to find earlier commits. The set of commits found by using these names ("branches") is also a "branch". So depending on what one means when one says "branch", you either do have the branches (the set of commits), or you do have the branches (the remote-tracking names), or you don't have the branches (you lack the local branch names).
Fortunately, if you have a remote-tracking name such as
origin/feature/mybranch-10XX
and you call for Git to switch to a (local) branch name:and that branch name does not exist yet, this invokes the
--guess
option, which is on by default:git switch
orgit checkout
meansgit switch --guess
orgit checkout --guess
.1 The guessing code intercepts the error that Git would have given, had you used--no-guess
. Git was about to say something to the effect that there is no localfeature/mybranch-10XX
, but then the guessing code intercepted the error. The guessing code scans through your remote-tracking names looking for one that matches up (after stripping off theorigin/
part in this case). If it finds one, it creates a new (local) branch name from the remote-tracking name, identifying the same commit. That commit is now "on" the (local) branch and "on" the remote-tracking name. It may also be on many other branches: commits are often on many branches at the same time, in Git.In any case, now that
git switch
orgit checkout
has used the guessing code to create the branch name, Git can switch to that branch. You will now have that particular commit checked out and can begin making changes and using those to make new commits.1If you don't want Git to guess, turn this off with
--no-guess
. In modern versions of Git you can also disable it by default as a configuration option.