Git指北:提交不上去的分支

文章目录

    • 背景说明
    • 操作步骤
      • 1. 查分支状态
      • 2. 建新分支dev
      • 3. 拉取已有分支
      • 4. 合并到当前分支
      • 5. 验状态

背景说明

同事有个git项目不能在IDEA中push,分支显示是灰色的,也不能切换分支。分支信息显示为:HEAD->d6b079ff

操作步骤

经过一番探索,此类问题解决方式如下:

1. 查分支状态

查看分支状态,显示不在任何分支上——“Not currently on any branch”:

E:\dwlijx_code\crm_pro>git status
Not currently on any branch.
nothing to commit, working tree clean

2. 建新分支dev

E:\dwlijx_code\crm_pro>git branch dev d6b079ff

根据各自项目的情况,建一个新分支就可以了。

3. 拉取已有分支

E:\dwlijx_code\crm_pro>git checkout master
Previous HEAD position was d6b079f Merge branch 'master' of https://gitee.com/cowboy2014/crm_pro into HEAD
Switched to a new branch 'master'
Branch 'master' set up to track remote branch 'master' from 'cowboy'.

4. 合并到当前分支

E:\dwlijx_code\crm_pro>git merge dev
Updating eabaccc..d6b079f
Fast-forward
 admin/src/main/resources/application-dev.yml         | 14 +++++++-------
 admin/src/main/resources/bootstrap.yml               | 10 +++++-----
 authorization/src/main/resources/application-dev.yml | 12 ++++++------
 authorization/src/main/resources/bootstrap.yml       |  6 +++---
 bi/src/main/resources/bootstrap.yml                  |  6 +++---
 core/src/main/resources/application-core.yml         |  2 +-
 crm/src/main/resources/bootstrap.yml                 | 10 +++++-----
 examine/src/main/resources/bootstrap.yml             | 10 +++++-----
 gateway/src/main/resources/application-dev.yml       | 12 ++++++------
 gateway/src/main/resources/bootstrap.yml             |  6 +++---
 job/src/main/resources/bootstrap.yml                 |  4 ++--
 oa/src/main/resources/bootstrap.yml                  | 10 +++++-----
 work/src/main/resources/bootstrap.yml                |  6 +++---
 13 files changed, 54 insertions(+), 54 deletions(-)

5. 验状态

E:\dwlijx_code\crm_pro>git status
On branch master
Your branch is ahead of 'cowboy/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

看到当前本地代码已经是master分支了,然后就可以再push到master分支了。

你可能感兴趣的:(Java实战宝典,git)