git push.default Update were rejected because a pushed branch tip is behand remote

2024-06-22 04:38

本文主要是介绍git push.default Update were rejected because a pushed branch tip is behand remote,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

现象:可以git pull下来,然后再git status,显示正常。

通过浏览器访问git地址,发现没有别人提交的修改,最新修改是自己提交的。

咨询同事,给出一个命令,就搞定可以正常push了。

git config --global push.default current


这句命令什么意思呢?指定push 的模式是current ,仅仅push 当前分支(这个分支名和远程分支名相同)到远程。怀疑我的错误是,其他分支的本地work被修改了,不能导致push被reject。


于是切换checkout到其他分支,逐个执行git status命令,返回结果都是正常的:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
 
nothing to commit, working directory clean


只有master分支不一样,提示结果
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded

然后执行git pull,把远程的master拉到本地。再运行git status,一切正常~~  
那么这个push.default到底是个什么东东,git help push 找到下面的解释。

push.default
Defines the action git push should take if no refspec is explicitly given. Different values are well-suited for specific workflows; for instance, in a purely central workflow (i.e. the fetch source is equal to the push destination), upstream is probably what you want. Possible values are:
 
nothing - do not push anything (error out) unless a refspec is explicitly given. This is primarily meant for people who want to avoid mistakes by always being explicit.
 
current - push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.
 
upstream - push the current branch back to the branch whose changes are usually integrated into the current branch (which is called @{upstream}). This mode only makes sense if you are pushing to the same repository you would normally pull from (i.e. central workflow).
 
simple - in centralized workflow, work like upstream with an added safety to refuse to push if the upstream branch’s name is different from the local one.
 
When pushing to a remote that is different from the remote you normally pull from, work as current. This is the safest option and is suited for beginners.
 
This mode has become the default in Git 2.0.
 
matching - push all branches having the same name on both ends. This makes the repository you are pushing to remember the set of branches that will be pushed out (e.g. if you always push maint and master there and no other branches, the repository you push to will have these two branches, and your local maint and master will be pushed there).
 
To use this mode effectively, you have to make sure all the branches you would push out are ready to be pushed out before running git push, as the whole point of this mode is to allow you to push all of the branches in one go. If you usually finish work on only one branch and push out the result, while other branches are unfinished, this mode is not for you. Also this mode is not suitable for pushing into a shared central repository, as other people may add new branches there, or update the tip of existing branches outside your control.
 
This used to be the default, but not since Git 2.0 (simple is the new default).
猜测原来的push模式是 matching,也就是每一次push 所有的分支到远程rep。
原来的设置已经被改成current,那如果再来一次的话,怎么查看自己系统的push模式呢?

shuohai@SHUOHAI-NOTE /e/dzk/GeocodingService (master)
$ git config --get push.default
current

显示当前的push.default的配置值是current,查看更多参数配置的命令是 git config
shuohai@SHUOHAI-NOTE /e/dzk/GeocodingService (master)
$ git config
usage: git config [options]
 
Config file location
    --global              use global config file
    --system              use system config file
    --local               use repository config file
    -f, --file <file>     use given config file
    --blob <blob-id>      read config from given blob object
 
Action
    --get                 get value: name [value-regex]
    --get-all             get all values: key [value-regex]
    --get-regexp          get values for regexp: name-regex [value-regex]
    --get-urlmatch        get value specific for the URL: section[.var] URL
    --replace-all         replace all matching variables: name value [value_regex]
    --add                 add a new variable: name value
    --unset               remove a variable: name [value-regex]
    --unset-all           remove all matches: name [value-regex]
    --rename-section      rename section: old-name new-name
    --remove-section      remove a section: name
    -l, --list            list all
    -e, --edit            open an editor
    --get-color <slot>    find the color configured: [default]
    --get-colorbool <slot>
                          find the color setting: [stdout-is-tty]
 
Type
    --bool                value is "true" or "false"
    --int                 value is decimal number
    --bool-or-int         value is --bool or --int
    --path                value is a path (file or directory name)
 
Other
    -z, --null            terminate values with NUL byte
    --includes            respect include directives on lookup


参考
 1 http://www.binkery.com/archives/381.html

 2 http://www.360doc.com/content/14/0213/16/10058718_352227358.shtml


原文地址:https://blog.csdn.net/arkblue/article/details/50439912 
 

这篇关于git push.default Update were rejected because a pushed branch tip is behand remote的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1083311

相关文章

brew install opencv@2 时报错 Error: Can't create update lock in /usr/local/var/homebrew/locks!

解决方案,报错里已经说明了: 我的解决方案: sudo chown -R "$USER":admin /usr/local   stackoverflow上的答案 I was able to solve the problem by using chown on the folder: sudo chown -R "$USER":admin /usr/local Also you'

Git的安装以及使用

一.简单介绍 1.1版本控制 版本控制是指对软件开发过程中各种程序代码,配置文件及说明文档等文件变更管理,是软件配置管理的核心思想之一。 版本控制最重要的内容是追踪文件的变更,它将什么时候,什么人更改了文件的什么内容等信息忠实的记录下来。除此之外,版本控制的另一重要的功能是并行开发。软件开发往往是多人协同作业,版本控制可以有效地解决版本的同步以及不同开发者之间的开发通信问题,提高开发效率。

BD错误集锦1——[Hive]ERROR StatusLogger No log4j2 configuration file found. Using default configuration:

错误描述:在使用IDEA进行jdbc方式连接到hive数据仓库时,出现以下错误:                ERROR StatusLogger No log4j2 configuration file found. 问题原因:缺少log4j2.xml文件   <?xml version="1.0" encoding="UTF-8"?><Configuration><Appender

Git代码管理的常用操作

在VS022中,Git的管理要先建立本地或远程仓库,然后commit到本地,最后push到远程代码库。 或者不建立本地的情况,直接拉取已有的远程代码。 Git是一个分布式版本控制系统,用于跟踪和管理文件的变化。它可以记录文件的修改历史,并且可以轻松地回滚到任何历史版本。 Git的基本概念包括: 仓库(Repository):Git使用仓库来存储文件的版本历史。一个仓库可以包含多个文件

mysql replace into 与 insert update

replace into 与 insert update 功能类似 总结下: replace into 是根据表中的唯一索引或主键来判断是否重复的。如果没有则replace into不起作用直接插入。 replace into如果遇到重复的值,会先把之前的数据删除,并且重新插入一条新的数据。效率可能不高 replace into的时候会删除老记录。所以其他表中所有与本表老数据主键i

通过sockst下载git

设置 Git 使用 SOCKS5 代理 git config --global http.proxy “socks5://localhost:1080” git config --global https.proxy “socks5://localhost:1080” 克隆仓库 git clone https://github.com/odoo/odoo.git 取消代理设置(可选) g

git clone [github]下载速度慢问题解决

将下面两个ip加入HOST 192.30.253.113 github.com 151.101.185.194 github.global.ssl.fastly.net 如果不起作用,登录 http://github.com.ipaddress.com/ (需要翻墙)输入 github.global.ssl.fastly.net 和 github.com查询对应的ip,修改host文件中的i

git fetch.git merge,git pull

git fetch origin branch1:branch2 首先执行上面的fetch操作 使用远程branch1分支在本地创建branch2(但不会切换到该分支),  如果本地不存在branch2分支, 则会自动创建一个新的branch2分支,  如果本地存在branch2分支, 并且是`fast forward', 则自动合并两个分支, 否则, 会阻止以上操作. Git pus

Eclipse使用git最基本流程

Eclipse使用git最基本流程,eclipsegit流程 git有诸多好处,网上都说的很清楚了,在这里我不再赘述。对于我来说,私下里想做一些项目,而又不能很好的保存自己的代码和进行版本控制,这时候,就用到了git。下面,就以我个人为例讲讲git从0开始如何安装使用。 Step1 准备工作 msysgit,下载地址为http://msysgit.github.io/

【已解决】在IDEA中使用Git拉取代码时提示:Can‘t update / master has no tracked branch

文章目录 问题描述原因分析解决方案 问题描述 在IDEA中使用Git拉取代码,尝试更新本地项目代码,提示 " Can't update / master has no tracked branch ",如下图所示: 原因分析 出现上述问题意味着本地名为master的分支(或者在很多新项目中为了更包容性已改为main作为默认分支名)并没有设置为跟踪任何远程分支。