摘要:使用git的时候多是在本地,而git远程分支的管理比较麻烦。在git使用的过程中,出现错误最多的命令大概是git push以后出现各种错误提示。本文主要解释git远程分支的基本运作原理,并总结git push出现的各种错误和解决方法。
本文来源:git远程分支的管理与git push错误汇总
1.与远程有关的配置
git fetch origin:
解释:Fetches named heads or tags from one or more other repositories, alongwith the objects necessary to complete them.
The ref names and their object names of fetched refs are stored in .git/FETCH_HEAD. This information is left for a later merge operation done by git merge.
说明:从指定的ref取得git分支,其中.git/FETCH_HEAD指明了分支的来源。
git merge:
解释:Incorporates changes from the named commits (since the time their histories diverged from the current branch) into the current branch.
明白git merge的来源:git merge nameOfbranch ,它是将指定的commit 或者tag merge到当前分支,但是它只是改变了工作目录的文件,并没有改变index和本地仓库。
git pull
Incorporates changes from a remote repository into the current branch.In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the currentbranch. With --rebase, it runs gitrebase
instead of git merge.
这个命令等于git fetch和git merge FETCH_HEAD以后的结果。
2.git push常见错误汇总
2.1错误一:
error: failed to push some refs to 'git@github.com:rickyfeng/wenda.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
出错原因:出现non-fast-forward ,往往是因为这样的情况:原来的提交记录是1.2-------1.3---------1.4,我们将1.4clone下来开发,同时别人也将1.4clone下来开发,然后别人先于我们而提交,产生了1.5版本:1.2------1.3------1.4------1.5,此时我们将修改过户的1.4版本提交到1.4版本上,必然会丢掉1.5这个记录,为了避免这种情况,我们在提交代码之前,先要进行pull
解决方法:pull,merge之后在push
总结中
分享到:
相关推荐
git 删除分支和回滚的实例详解 【git 删除本地分支】 git branch -D br 【git 删除远程分支】 git push origin :br (origin 后面有空格) git代码库回滚: 指的是将代码库某分支退回到以前的某个commit id 【本地...
介绍了如何从git客户端克隆远程仓库的分支,并建立跟踪关系 步骤较为详细,希望对初学者有用
GIT分支管理 远程分支 本地分支 GIT分支管理 远程分支 本地分支
参与任何一个 Git 项目的协作,必须要了解该如何管理远程仓库... 管理远程仓库的工作,包括添加远程库,移除废弃的远程库,管理各式远程库分支,定义是否跟踪这些分支,等等。该文档很好的讲解了git的远程仓库的使用。
git分支管理策略,git分支管理策略,git分支管理策略,git分支管理策略
企业git分支管理pdf
Git 创建分支提交远程分支详解 1.创建本地分支 git branch 分支名,例如:git branch 2.0.1.20120806 ...4.远程分支和本地分支需要区分好,所以,在从服务器上拉取特定分支的时候,需要指定远程分支的名字。
使用git管理项目的时候,通常会有多个分支,在多个分支的情况下,如何管理项目,如何在本地,远程仓库管理项目。
GIT分支代码统计,安人员统计,分2步,第一步完成后可以手动修改统计的异常数据,然后执行第二部,得到更准确的统计数据。
详细讲解git分支管理,适合于代码管理、项目管理等工作。
适用于懂git基本操作的玩家,使用git管理python代码,方便控制版本。简单的整理了一下文档,请大家多多支持。
介绍了Git分支和标签的原理及使用方法,Git分支内容包括Git原理、创建分支、合并分支、上传本地分支、跟踪远程分支等。Git标签内容包括查询Git标签、添加Git标签、为历史提交记录添加Git标签等。
前后端都是适用的git创建文件夹命令,git代码分支管理规范,图示方式更容易理解git代码分支管理规范
彻底解决Mac端git clone/push速度太慢的问题,详情请参阅文档。
该文档定义了分支管理规范-GIT分支流程开发规范。
3. 查看本地分支和远程分支 git branch -a *master remotes/origin/master 4. 创建分支 *新建一个分支,但依然停留在当前分支 git branch [branch-name] *新建一个分支,并切换到该分支上 git branch -b [branch-...
Git实战学习视频教程 Git多场景应用学习 Git服务器和远程分支 Git多人协作开发项目
针对使用git和jenkins进行持续集成的情况,在jenkins平台上,只创建一个job,却想实现git上不同分支的构建,并且还不能影响自动构建的分支,本文将针对这一问题进行图文讲解