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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 七、springboot整合flowable(工作流)

    七、springboot整合flowable(工作流)springboot整合flowable(工作流)简介Flowable适用于开发人员,系统管理员和业务用户的紧凑且高效的工作流程和业务流程管理(BPM)平台。Flowable的发布包里包含了大部分源码,以JAR文件方式提供。Flowable的源码也可以通过以下链接获得:https://github.com/flowable/flowable-engine准备工作pom….

    2022年5月21日
    92
  • 全局平均池化(全局池化代替全连接层)

    全局平均池化是在论文NetworkinNetwork中提出的,原文中全局平均池化的作用和优点:思想:对于输出的每一个通道的特征图的所有像素计算一个平均值,经过全局平均池化之后就得到一个维度==类别数的特征向量,然后直接输入到softmax层作用:代替全连接层,可接受任意尺寸的图像优点:1)可以更好的将类别与最后一个卷积层的特征图对应起来(每一个通道对应一种…

    2022年4月18日
    222
  • Swoole来实现实时异步任务队列

    Swoole来实现实时异步任务队列

    2022年2月10日
    39
  • WinForm和WPF的区别「建议收藏」

    一、控件的差异作为Windows桌面UI开发的两大.net开发库,WinForm和WPF同时存在着。之所以功能如此重合的两个库同时存在,是因为两者的底层差异非常大,WinForm底层依赖于传统的Win32API,特别是User32.dll;而WPF则底层依赖于Direct3D。而我们知道User32和Direct3D两者是平行存在,彼此独立的。WPF之前几乎所有的WindowsUI开发都依赖于User32,当然游戏除外。随着Direct3D的日趋成熟和显卡的普通性能提升,微软力图改变这种状况,所以开发

    2022年4月12日
    55
  • 杭电 1142 十字链表存储

    杭电 1142 十字链表存储  本来是想用二维数组实现的,但是想了一下发现,如果数据是稀疏矩阵的话,用二维数组存就会造成很多的空间浪费,而且遍历的时候也很浪费时间。学数据结构的时候书上教我们使用十字链表来存储稀疏矩阵,于是就想着用十字链表来实现。然后我发现我忘了十字链表的代码实现了…默默地去翻书,捣置了好久,终于写好了,乐滋滋的去oj提交代码,结果时间超限……  哎~把代码贴上来,就当加深一下十字链表的记忆吧~~#in…

    2022年6月18日
    24
  • 各种开源SLAM算法「建议收藏」

    各种开源SLAM算法「建议收藏」OpenSLAMhttp://openslam.org/FALKOLib(2DLIDAR)GMapping,GridSLAM(Tolearngridmapsfromlaserrangedata)tinySLAM(Laser-SLAMalgorithmin200linesofCcode)UnscentedFastSLAM(Laserdata,M…

    2022年6月16日
    58

发表回复

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

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