在 Eclipse 中,从使用本地存储库中的 master 分支切换到其他分支



我在 Git 中创建了一个空项目。我还在 Eclipse 中创建了一个 Java EE 项目(注意:Eclipse 安装了 Git 插件(。

在 Eclipse 中,我访问并复制了本地机器(或者更确切地说是笔记本电脑(上的(空(Git Repository 项目。

然后,我在Java EE项目中编写了一些代码。

From within the project, I then used the Team -> Commit option on it to :
1) Add the project to the Local Repository
2) Commit and push the contents from the Local Repository to the Git Repository.

我的问题是所有这些工作都是使用 Master 分支完成的。

Git 存储库当前位于主分支上。 本地存储库当前位于主分支上。

每当我对项目进行更改并执行团队>提交时,所有操作都会与 Master 分支一起发生。 大师 ->大师

What I would like to do is as follows: 
1) create 3 more branches in Git Repository (called consolidation, testing, production) - each new branch would be a copy of the Master Branch
2) On the Eclipse side, I need to fix it so that when any changes are made and saved to the Local Repository, the data will be saved to the
Consolidation Branch of the Local Repository and ~NOT~ the Master Branch (which is what happens now).
3) After saving data in the Consolidation Branch, from then on out, when code is sent to the Git Repository, it would be done by using the Consolidation branch and NOT the Master branch.

我该怎么做?

蒂亚

更新

@Howlger 您好,感谢您的回复!您的建议为我提供了如何解决问题的线索。首先,我登录 Git 并将 Master 分支复制到"dev"分支。

接下来,我在 Eclipse 下切换到 Git 透视图(本地(,并为我的项目创建了一个"dev"分支:

分支 -> 切换到 -> 新分支

然后,我遵循了您的一些建议,除了我创建了一条允许

分支 : 开发 (

本地( => 分支 : 开发 (远程(

它位于"高级"按钮下。

我做了一个小测试,它奏效了。再次感谢!

再次更新嗨 - 只是登录以注意到我更改了引用,以便

Source Ref = refs/heads/*
Target Ref = refs/heads/*

本地分支到远程/上游存储库分支的映射由推送引用映射指定。看起来您当前的推送引用映射HEAD:refs/heads/master:您当前的本地分支将被推送到远程/上游存储库分支。要将本地分支映射到具有相同名称的远程/上游存储库分支,只需删除所有推送引用映射:

  1. 在 Git 存储库视图中,单击源>推送节点>远程,然后选择配置推送...
  2. 选择映射,然后单击删除
  3. 点击保存

有关更多详细信息,请参阅 EGit 用户指南> 推送引用规范。

最新更新