赞
踩
1.You have unmerged files
- $ git status
- On branch master
- You have unmerged paths.
- (fix conflicts and run "git commit")
- Unmerged paths:
- (use "git add <file>..." to mark resolution)
- both modified: index.html
- no changes added to commit (use "git add" and/or "git commit -a")</file>
解决方案:查看发生冲突的文件,手动修改后commit,通过 git mergetool 可以看到图形化的界面,便于直观的理解。
2.add操作warning
- $ git add -A
- warning: LF will be replaced by CRLF in file
- The file will have its original line endings in your working directory.</code>
原因:Linux平台下的换行符是 LF,而Windows下则是 CRLF,所以当你再 Windows 保存文件时候,换行符会被保存为
建议:统一换行符为 LF
解决方案:Git 命令行输入如下命令,禁止自动转换换行符
git config --global core.autocrlf false
3.git pull 失败
- You have not concluded your merge (MERGE_HEAD exists).
- Please, commit your changes before you can merge.
原因:之前进行 Pull 操作时自动合并失败,和原文件有冲突
解决方案:取消 Pull 操作然后手动合并
取消合并:
git merge --abort
git reset --merge
解决冲突 重新 add and commit 拉取分支然后合并,git pull
4.push error
- $ git push origin master
- To john@githost:simplegit.git
- ! [rejected] master -> master (non-fast forward)
- error: failed to push some refs to 'john@githost:simplegit.git'
原因:之前有人进行过提交,本地项目并不是最新的,在提交之前,必须合并当前分支至最新
解决方案:git merge origin/master,当你直接在master分支的时候,可以
git pull,相当于
git fetch + git merge
5.checkout:unable to create '/path/project/.git/index.lock'
Git - fatal: Unable to create '/path/my_project/.git/index.lock': File exists.
解决方案:rm -f ./.git/index.lock
有一条准则谨记,任何命令中带有 –hard 参数的都谨慎执行,很有可能造成不可逆的损失。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。