branch_git fetch

branch_git fetch问:Igoogledandreadmanyposts,butnonecouldmakemeunderstandthebranchdivergenceproblemyet.IfI’veremotetrackingbranch,Ioftengetintothefollowing:$gitstatus#Onbranch

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

问:

I googled and read many posts, but none could make me understand the branch divergence problem yet.

If I’ve remote tracking branch, I often get into the following:

$ git status
# On branch feature/worker-interface
# Your branch and 'origin/feature/worker-interface' have diverged,
# and have 1 and 4 different commit(s) each, respectively.

Jetbrains全家桶1年46,售后保障稳定 答:

First, you can use the cherry command to see what commits differ between branches, and in what ways. So in this case, running g cherry origin/feature/worker-interface shows us the status of commits on the current branch and how they stack up against origin/feature/worker-interface. You will find 1 repo which you forgot to commit.

首先,你可以使用git cherry命令查看提交的分支的不同,也就是说你可以git cherry origin/master 查看,显示在当前分支origin/master下提交的状态,你将发现有1个版本库你忘记了提交。

Now, lets see whats happening with the ‘origin/feature/worker-interface’ and its commits.For this we can run a log command with a special format gl ..origin/feature/worker-interface --oneline

现在,让我们看看origin/master到底发生了什么情况,我们用git log ..origin/master --online 查看。

Here we see 4 commits that don’t exist in our current branch

我们发现有4个提交在我们的当前分支下不存在。

So now we have a good idea of what’s happened. you’ve made 1 commits on your local master branch, and it looks like there are 4 commits on origin/feature/worker-interface which you don’t have merged in yet. So, you could just blindly merge things together and go on your way (if they merge without conflict), but I’d like to show you how to deal with it in a more controlled manner.

所以我们很想知道这到底是什么原因导致了这种情况的发生。你在本地的master分支提交了一次,但是看上去应该是四次提交,这四次提交你都还没有进行合并过。那么,你可能盲目的把它们进行合并,但我将告诉你这应该怎么更好的处理这个问题:

1) First, create a branch that points to your current HEAD: gco -b local_changes 2) Now that we have that to keep track of those changes, we switch back to feature/worker-interface: gco feature/worker-interface 3) At this point, reset the feature/worker-interface branch to get rid of the 1 commit. 4) There you go! You can check your status of branch git status you will be prompted asnothing to commit


1),你应该创建一个分支指向你当前的HEAD ,如果有分支可以不用创建(git checkout -b local_changes)

2) 现在我们可以追踪到分支上的变化,我们切回到origin/master ,git checkout origin/master

3)之后git reset origin/master 删除origin/master 分支上的一次提交

4)OK,完工。git status查看下。

参考:http://stackoverflow.com/questions/9189413/good-and-clear-understanding-of-the-git-branches-diverged-issue

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/213416.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • excel怎么生成xml文件_Excel文件格式或扩展名无效

    excel怎么生成xml文件_Excel文件格式或扩展名无效JS将数据生成Excel(XML)并保存为.xls文件,已封装可以直接使用简单写法:<?xmlversion=”1.0″encoding=”UTF-8″?><?mso-applicationprogid=”Excel.Sheet”?><Workbookxmlns=”urn:schemas-microsoft-com:office:spreadsheet”xmlns:o=”urn:schemas-microsoft-com:office:office..

    2022年8月22日
    3
  • 方差分析法

    方差分析法前言工程实现的过程中需要对提取的特征指标进行有效性分析,评价各个特征指标与分类器不同类别的显著性关系,筛选出对不同类别判别贡献率最佳的指标,为设计分类器等提供支持。本文主要针对单因子方差分析法。实现步骤1.方差分析法的原理;2.数据准备;3.单因子方差分析法的matlab实现;4.特征的多重比较检验;实现过程1.方差分析法的原理;方差分析法(Analys…

    2022年10月16日
    0
  • 数据库设计概念结构设计_数据库设计典型实例

    数据库设计概念结构设计_数据库设计典型实例文章目录数据库设计概念设计结构概念结构设计ER模型的基本元素实体/实体集属性区别实体和属性联系二元联系的关系1:11:nm:n一元联系1:11:nm:n三元联系采用ER模型的概念设计设计局部ER模型例题设计全局ER模型全局ER模型的优化数据库设计数据库设计:构造最优的数据模型,建立数据库及其应用系统的过程数据库设计的好坏非常重要概念设计结构概念设计的目标是产生反映用户需求的数据库概念结构,即概念模型概念模型具有硬件独立、软件独立的特点处于一个桥梁作用概念设计的主要步骤

    2022年10月12日
    0
  • 入园记——我的DBA之路

    入园记——我的DBA之路

    2021年9月10日
    48
  • 手机号码归属地数据库下载

    手机号码归属地数据库下载一份手机号归属地数据,共有174495条数据,包括中国移动,中国联通,中国电信的(包含152、186、188、189开头的手机号)。其中cardtype字段基本上没有什么用。因为可以通过办理某些业务就可以把如全球通卡转成神州行卡。对于这样的一份数据,你想要怎么利用?如果你只是想做一个手机号归属地查询的功能,那就浪费了。这个收数据库的主要功能就是通过手机号的前7位数字判断出手机号的归属城…

    2022年7月22日
    46
  • 如何安装wget_ubuntu安装unzip命令

    如何安装wget_ubuntu安装unzip命令今天给服务器安装新LNMP环境时,wget时提示-bash:wgetcommandnotfound,很明显没有安装wget软件包。一般linux最小化安装时,wget不会默认被安装。可以通过以下两种方法来安装:1、rpm安装rpm下载源地址:http://mirrors.163.com/centos/6.2/os/x86_64/Packages/下载wget的RPM包:htt…

    2022年10月17日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号