有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :

git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)


当前回答

这将为未命名的远程来源( 文档) 提供宽度 :

$ git checkout -t remote_name/remote_branch

添加新的远程,您需要首先做以下操作:

$ git remote add remote_name location_of_remote
$ git fetch remote_name

第一次告诉遥控器的存在, 第二次得到承诺。

其他回答

如果分支位于来源远程以外的某物上,我愿意做以下工作:

$ git fetch
$ git checkout -b second/next upstream/next

此选项将检查上游边远处的下一个分支, 到一个名为第二个/ 下一个的本地分支。 这意味着如果您已经拥有下一个命名为本地分支的分支, 就不会发生冲突 。

$ git branch -a
* second/next
  remotes/origin/next
  remotes/upstream/next

git 检出 -b “branch_name” [b 意指创建本地分支]

git 分支-all

git 检出 - b “ 您的分支名称 ”

git 分支分支

git 拖拉源 "你的分支名称"

从母版分支向 dev 分支成功退出

使用抓取来拉动全部远程

   git fetch --all

列表远程分支 :

   git branch -r

列表所有您的分支

   git branch -l
   >>outpots like-
     * develop
       test
       master

要取出/更改分支

   git checkout master

tl; dr , tl; dr

使用 git 开关而不是 git 检出。 更多详情请见此页面 。

我认为答案已经过时。 git 将一些退票功能分割为切换和现在恢复 。

以下是我的总结:

如果您想要为远程分支更新一些内容, 您应该创建一个本地分支以“ 跟踪” 远程分支。 您可以在本地更新任何您想要更新的内容, 并最终推到远程 。 如果您在克隆您的仓库后直接检查到远程分支, 您可能会看到“ 标记头” 状态, 并从 git 中看到以下信息 :

Note: switching to 'origin/asd'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at d3e1083 Update a

如何建立本地分支跟踪远程分支?

要创建本地分支以跟踪远程分支, 您可以使用 git checkout & lt; remote 分支名 & gt; 或 git 开关 &lt; remote 分支名 & gt; 。 如果您有一个文件或文件夹与您的远程分支名有相同名称, git checkout 会输出一些错误消息, 但是 git 开关通常可以正常工作 。

例如:

查看所有分支, 我们想要创建一个本地分支, 以跟踪远程分支遥控器/ 原发/ ass 。 我们也有一个文件名称 : $ git 分支 - a * 主遥控器/ 原发/ 头发- & gt; 原发/ 主遥控器/原发/ 原发/ 远地/ 原发/ 原发/ 原发/ zxc $ 。 以文件名和文件名相同 。 如果我们使用 Git 检查命令创建本地分支以跟踪远程分支 $ git 检查结果, git 则应该输出一些错误信息 。

git 分支 -r 表示对象名称无效, 因为该分支名称不在 Git 的本地分支列表中。 从源头更新您的本地分支列表 :

git remote update

然后尝试再检查一下你的远程分支。

这是为我工作。

我相信在所有偏远的树枝里都会拉拉, 这并不是最初的海报所希望的。