产生原因

因为你在pull或者fetch原作者代码的时候会产生新的commit记录,这条commit其实是让你的库和原作者的库代码一致,但是却会生成一条和你修改代码后提交的commit一样的记录,导致你的仓库的基(base)和原作者的仓库的基(base)产生偏移,所以

git会提示

Your branch is ahead by X commits

解决方案

当你的github fork的仓库提示 Your branch is ahead by X commits,但是其实你确定你的代码和主库是一样的时候你可以:

 git rebase upstream/master

解释:将你本地库的base重新定位到和upstream(也就是原作者的库)一样。

然后:

git push origin master -f

解释:强行将本地的代码推到你自己的github仓库上(加-f前一定要确定你的代码和upstream的代码是一样的)。

强行push到你的代码仓库之后,你的github页面将显示:

This branch is even with xxxxx:master.

说明你的github库的代码也和原作者的代码库保持一致了。

git: Your branch is ahead by X commits 的解决方案相关推荐

  1. Git Your branch is ahead of ‘origin/master‘ by X commits解决方法

    Git Your branch is ahead of 'origin/master' by X commits解决方法 参考文章: (1)Git Your branch is ahead of 'o ...

  2. [git] your branch is ahead of ... 解决办法

    [git] your branch is ahead of ... 解决办法 出现该问题表示在次之前已经有X个commite了,执行命令 git reset --hard HEAD~X 解决其中X表示 ...

  3. Git Your branch is ahead of 'origin/master' by X commits解决方法

    解决办法: 如果当前分支的东西想保留,就直接提交到线上分支 git push origin [当前分支名] 如果当前分支的东西不要了,目的是与线上保持一致 git reset --hard origi ...

  4. Git Your branch is ahead of ‘origin/master‘ by X commits解决

    方法1 git fetch origin 方法2:代码的确需要 git push origin 方法3 :代码不需要 git reset --hard origin/$branch 可以先执行下git ...

  5. git 报错解决方法:Your branch is ahead of ‘origin/dev‘ by 65 commits.

    git status 发现如下信息解决办法: Your branch is ahead of 'origin/dev' by 65 commits. If your local changes are ...

  6. Git中Your branch is ahead of ‘origin/master‘ by x commits的解决办法

    @[TOC]Git中Your branch is ahead of 'origin/master' by x commits的解决办法 问题描述:新的全局用户名下,修改原有本地库的代码,上传时遇见的问 ...

  7. push后再git status出现Your branch is ahead of ‘xxx‘ by 1 commit.

    当你push到远程仓库后,在远程仓库合并时起冲突的部分被丢弃后,再使用git status,会出现Your branch is ahead of 'xxx' by 1 commit,此时是因为你的本地 ...

  8. Your branch is ahead of ‘origin/main‘ by 1 commit.

    Your branch is ahead of 'origin/main' by 1 commit.(use "git push" to publish your local co ...

  9. Git master branch has no upstream branch的解决

    Git master branch has no upstream branch的解决 在push代码时,出现"git master branch has no upstream branc ...

最新文章

  1. cefsharp 发送请求服务器_WEB服务器之HTTP协议
  2. linux 内核 netfilter 网络过滤模块 (3)-NAT
  3. Win服务器2008和2012哪个更好?
  4. EKPO-PSTYP
  5. java Web发布的两种方式
  6. SQL SERVER 2005 同步复制技术 发布与订阅功能使用说明
  7. 理解并实施:GLBP(ccna200-120新增考点)
  8. 【狂神MySQL笔记】常用命令行语句(1)
  9. Java数据结构与算法——图
  10. kux格式怎么转换成mp3_kux格式如何转换成mp4、mp3?
  11. javaweb框架学习开端
  12. 我的博客生涯开始……
  13. 种子点生长算法(上)——二维种子点生长
  14. B站 bilibili 视频、分区、up主数据合集
  15. 毕业设计——基于Spring boot框架的 AI智能大数据医疗诊断平台
  16. std::tuple、std::tie(可用于结构体大小比较)、std::pair用法
  17. 远离那些聪明,却不厚道的人
  18. 软件测试之实用小工具推荐
  19. 北大操作系统陈向群第六章知识点
  20. 无线传感网课后习题(书本名称无线传感器网络基础 : 理论和实践 : Fundamentals of wireless sensor networks : theory and practice)

热门文章

  1. Java八股——wait、sleep与park
  2. 时间表、行程安排表以及日历日程的SilverLight控件MindFusion.Scheduling
  3. 新手学习广告设计要如何培养广告思维
  4. 降价到29万!!特斯拉的屠杀开始了
  5. python自动发邮件报554错误_python==使用smtp发送邮件的源代码,解决554错误码的问题...
  6. 安卓开发工具汇总,开发人员必备!
  7. mobaxterm怎么解除sessions个数限制_广发信用卡特定商户交易被限制怎么解决?多久解除?其实没那么复杂...
  8. 最新版Crack:Xceed Ultimate Suite
  9. pow函数python_python pow函数怎么用
  10. C++中求string类型字符串的长度的方法