无法在远程找到远程git分支 - bitbucket

发布于 2025-01-22 11:29:13 字数 514 浏览 0 评论 0原文

切换到新机器。我需要拉出从旧机器推到遥控器的工作分支。但是我无法通过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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遥远的绿洲 2025-01-29 11:29:13

您已经有那些分支机构。它们命名为Origin/feation/myBranch-10xxonect> onect/feation/mybranch-5xx

这些不是分支。相反,它们是分支。如果您想在这些分支上工作,则需要从这些分支机构制作分支。如果这没有道理,那么您正在正确阅读它:git 过度过多的分支一词,以至于失去了所有含义。 是什么意思?

(请参阅“分支”?我们到底 (或至少不是分支)。使用以下单词:

  • 远程跟踪名称:origin/mainonect> onement/fartial/mybranch-10xx之类的名称;
  • 分支名称(或“本地分支”,如果您愿意的话):mainfeature/myBranch-10xx之类的名称;和
  • 提交:由大丑陋的哈希ID所识别的东西。

git将使用名称(分支名称和远程跟踪名称)查找提示的哈希ID(s),然后将使用这些提交来查找早期的提交。使用这些名称(“分支”)找到的一组提交也是“分支”。因此,根据一个人说“分支”的含义,您要么有分支(提交的集合),要么确实有分支(远程跟踪名称),或者您没有分支(您缺少本地分支名称)。

幸运的是,如果您有一个远程跟踪名称,例如onement/feation/myBranch-10xx,则要求git切换到(本地)分支名称:

git switch feature/mybranch-10XX

而该分支名称​​不存在,它调用- 猜测选项,默认情况下为:git switchgit Checkout MENE git Switch - guessgit Checkout -guess 1 猜测代码拦截了git 的错误如果您使用- no-guess会给出。 git是关于 的,要说的话是没有本地功能/myBranch-10xx的效果,但是猜测代码截获了错误。猜测代码通过您的远程跟踪名称扫描,以寻找与之匹配的名称(在这种情况下删除了Origin/部分之后)。如果找到一个,则它将从远程跟踪名称中创建一个新的(本地)分支名称,识别相同的提交。现在,该提交是在“远程跟踪名称”上的(本地)分支“”上“”。它也可能在许多其他分支上:在git中,通常在许多分支机构上。

无论如何,既然git switchgit Checkout已将猜测代码使用到 create 的分支名称,git可以切换该分支。现在,您将拥有该特定的 commit 检查,并可以开始进行更改并使用这些更改来进行新提交。


1 如果您不希望git猜测,请使用- no-guess关闭。在现代版本的GIT版本中,您还可以默认情况下将其作为配置选项禁用。

You already have those branches. They're named origin/feature/mybranch-10XX and origin/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:

  • remote-tracking name: a name like origin/main or origin/feature/mybranch-10XX;
  • branch name (or "local branch", if you prefer): a name like main or feature/mybranch-10XX; and
  • commit: the thing that is identified by a big ugly hash ID.

Git 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:

git switch feature/mybranch-10XX

and that branch name does not exist yet, this invokes the --guess option, which is on by default: git switch or git checkout means git switch --guess or git 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 local feature/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 the origin/ 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 or git 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文