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

时间:2017-07-27 20:33:49

标签: eclipse git branch

我在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 Repository目前位于Master分支上。 本地存储库目前位于主分支上。

每当我对项目进行更改并执行团队 - >提交,所有操作都发生在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.

我该怎么做?

TIA

更新

@Howlger 嗨,谢谢你的回复!你的建议给了我一个如何解决问题的线索。首先,我登录Git并将Master分支复制到" dev"分支。

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

  

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

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

的路径
  

branch:dev(local)=> branch:dev(remote)

它属于" Advanced"按钮。

我做了一个小测试,但它确实有效。再次感谢!

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

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

1 个答案:

答案 0 :(得分:1)

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

  1. 在Git Repositories视图中,右击遥控器>来源>按节点并选择配置推送...
  2. 选择映射,然后单击删除
  3. 点击保存
  4. 有关详细信息,请参阅EGit User Guide > Push Ref Specifications