"On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to ..."解决
来源:互联网 发布:机器人c语言编程实例 编辑:程序博客网 时间:2024/06/05 10:09
在git使用时,需要将本地修改的代码提交到远程库时,push时却出现以下错误
To ssh://git@localhost:*/user/project.git ! [rejected] master -> master (fetch first)error: failed to push some refs to 'ssh://git@localhost:*/user/project.git'hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.
查看git status出现以下提示:
On branch masterYour branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits)nothing to commit, working directory clean
这是为什么呢?
原因是,在你关联本地库和远程库以后,两者的文件是一致的,之后,你修改了本地库的文件,同时远程库的文件也被你修改了。当两者都有修改的时候,由push方(这里是本地库)来先做远程库和本地库的合并之后,再提交本地库的修改到远程库。因此需要在commit和push之间,做pull操作,即按以下步骤提交修改:
git add *git commit -m 'change'git pullgit push origin master
输出的log中没有error或hint,提交成功啦~恭喜(ps:其实当出现错误时,输出的log中都已经告诉大家解决方案啦~)
阅读全文
0 0
- "On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to ..."解决
- Git Your branch is ahead of 'origin/master' by X commits解决方法
- Your branch is ahead of 'origin/master' by 1 commit
- Your branch is ahead of 'origin/master' by 1 commit
- Your branch is ahead of 'origin/master' by 1 commit
- git Your branch is ahead of 'origin/master'
- git出错"Your branch is ahead of 'origin/LS3A_2H' by 4 commits"解决
- why does it say “Your branch is ahead of origin/master
- [小技巧] git: Your branch and 'origin/master' have diverged
- git: Your branch and 'origin/master' have diverged
- git: Your branch and 'origin/master' have diverged
- git: Your branch and 'origin/master' have diverged
- Your branch and 'origin/master' have diverged, and have 1 and 1 different commits each, respectively
- Git: push 出错的解决 master -> master (branch is currently checked out)
- Git: push 出错的解决 master -> master (branch is currently checked out)
- [Linux] Git: push 出错的解决 master -> master (branch is currently checked out)
- Git: push 出错的解决 master -> master (branch is currently checked out)
- [Linux] Git: push 出错的解决 master -> master (branch is currently checked out)
- oracle查询机构树
- 常用权限依赖
- QueryUnLoad->Unload->Terminate
- StringBuffer类
- js中间隔一段时间打印数组中的值
- "On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to ..."解决
- 拓展KMP算法
- mac下简单配置Tomcat
- sudo命令用其他身份来执行命令,限制root远程登录详解
- jquery中$.ajax提交form文件
- Hive导入10G数据的测试
- 项目小案例画一个进度条,中间还有进度的百分比
- 阿里云配置nginx反向代理tomcat
- 三角形的判定