1.错误一:
今天在服务器上git pull是出现以下错误:
error: Your local changes to the following files would be overwritten by merge:
application/config/config.php
application/controllers/home.php
Please, commit your changes or stash them before you can merge.
Aborting
不知道什么原因造成的代码冲突,处理方法如下:
如果希望保留生产服务器上所做的改动,仅仅并入新配置项:
git stash
git pull
git stash pop
然后可以使用git diff -w +文件名 来确认代码自动合并的情况.
如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:
git reset --hard
git pull
反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:
git reset --hardgit pull
其中git reset是针对版本,如果想针对文件回退本地修改,使用
git checkout HEAD file/to/restore
2.错误二:
git-updating-currently-checked-out-branch-warning
Counting objects: 3, done.
Writing objects: 100% (3/3), 226 bytes, done. Total 3 (delta 0), reused 0 (delta 0) remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD. remote: error: remote: error: You can set 'receive.denyCurrentBranch' configuration variable to remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into remote: error: its current branch; however, this is not recommended unless you remote: error: arranged to update its work tree to match what you pushed in some remote: error: other way. remote: error: remote: error: To squelch this message and still keep the default behaviour, set remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. To git@192.168.45.42:teamwork.git ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to 'git@192.168.45.42:teamwork.git'解决方法:
git config receive.denyCurrentBranch ignore
这里详细记录下
http://stackoverflow.com/questions/738154/what-does-git-updating-currently-checked-out-branch-warning-mean
根据stackoverflow上的讨论记录,默认的git init建立的仓库所处分支master的情况下不允许向自己的远程分支提交,
所以最终的解决方案是建立裸库 也就是 git init --bare 或者 git init --bare --share
3.错误三:
cannot-update-paths-and-switch-to-branch-at-the-same-time
$ git checkout -b test --track origin/masterfatal: Cannot update paths and switch to branch 'test' at the same time.Did you intend to checkout 'origin/master' which can not be resolved as commit?解决方案:
git remote -v
git fetch origin
然后重新执行刚才的track命令,成功
4.错误四
error: Malformed value for push.default: simple error: Must be one of nothing, matching, tracking or current.解决方案:
git config --global push.default upstream
5.错误五
提交后提示
fatal: recursion detected in die handler问题原因:问题原因是http.postBuffer默认上限为1M所致。在git的配置里将http.postBuffer变量改大一些即可,比如将上限设为500M:git config --global http.postBuffer 524288000