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)
上一篇 2025年7月23日 下午4:15
下一篇 2025年7月23日 下午4:43


相关推荐

  • 国外企业电子邮箱大全,国外用邮箱哪个好?怎么注册国外邮箱?「建议收藏」

    国外企业电子邮箱大全,国外用邮箱哪个好?怎么注册国外邮箱?「建议收藏」外贸、物流、留学移民等公司都会用到能往国外发邮件的邮箱。在知乎上看到,TOM企业邮箱国内国外都能用,移动办公也方便。国外用邮箱群发邮件群发开发信、给客户群发节日祝福都会企业邮箱的邮件群发功能。用群发单显能起到事半功倍的效果,如下图,登录邮箱后,点击【写邮件】,再点击【群发单显】就能一次几百封的群发邮件了。如何是给公司所有员工群发邮件通知,还是邮件群组更方便。像微信群一样,把所有人拉到一个群组里,往这个组里发通知,群里其他人都能收到,适用于公司内部多部门、跨地区管理沟通。TOM这个国际邮箱之所以用的

    2022年7月12日
    75
  • 路径分析如何操作?模型如何修正?

    路径分析如何操作?模型如何修正?一、研究场景路径分析,也称通径分析(有时也称结构方程模型,一般情况下如果包括测量模型和结构模型,则称为结构方程模型;如果只包括结构模型,则称为路径分析)。路径分析在于研究模型影响关系,用于对模型假设进行验证。比如下图的模型框架:希望研究工作条件,人际关系对于公司满意度的影响;同时还希望研究公司满意度和机会感知对于离职倾向的影响。路径有一共有4条(即4对影响关系),路径分析可以同时研究此4对影响关系。二、SPSSAU操作1.SPSSAU上传数据登录账号后进入SPSSAU页面,点击右上角..

    2022年8月24日
    8
  • [SpringCloud系列004] SpringCloud和dubbo有哪些区别?

    [SpringCloud系列004] SpringCloud和dubbo有哪些区别?原https://blog.csdn.net/anningzhu/article/details/76599875一.两者的模块组成:1、Dubbo主要分为服务注册中心,服务提供者,服务消费者,还有管控中心;2、相比起Dubbo简单的四个模块,SpringCloud则是一个完整的分布式一站式框架,他有着一样的服务注册中心,服务提供者,服务消费者,管控台,断路器,分布式配置服务,消息总线,…

    2022年5月20日
    36
  • 伽马(gamma)函数_伽马分布的分布函数怎么求

    伽马(gamma)函数_伽马分布的分布函数怎么求一。ΓΓ\Gamma分布指数分布是两次事件发生的时间间隔ΓΓ\Gamma分布是n倍的指数分布即,ΓΓ\Gamma分布表示发生n次(αα\alpha次)事件的时间间隔的概率分布可以直观地认为ΓΓ\Gamma分布是Possion分布在正实数集上的连续化版本Possion(X=k|λ)=λke−λk!Possion(X=k|λ)=λke−λk!Possion(X=k|\lambda…

    2025年8月23日
    9
  • EXT中的apply方法

    EXT中的apply方法Ext.apply=function(o,c,defaults){if(defaults){//no"this"referenceforfriendlyoutofscopecallsExt.apply(o,defaults);}if(o&&c&&typeofc==…

    2022年7月28日
    9
  • MySQL的数据表中的约束有以下5种_数据库增加约束条件

    MySQL的数据表中的约束有以下5种_数据库增加约束条件MySQL数据库中数据表的约束条件

    2022年10月10日
    4

发表回复

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

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