git常见问题


这些是在使用git中遇到的问题,和解决这些问题的方法:
1) you need to resolve your current index first
[cc lang=’c’]
rong:wang_iOS apple$ git checkout develop
eqi/Info.plist: needs merge
error: you need to resolve your current index first
[/cc]
分析:这是在分支切换的时候,执行  git pull (fetch+merge = pull),由于长时间没有和remote分支merge,分支间的冲突,解决这个冲突就好了。
解答:

2) Updates were rejected because the tip of your current branch is behind
[cc lang=’c’]
localhost:chexun_iOS apple$ git push
To git@git.eqi.cc:mobile/wang_iOS.git
! [rejected] develop -> develop (non-fast-forward)
! [rejected] feature_praiseDetail_commentList -> feature_praiseDetail_commentList (non-fast-forward)
error: failed to push some refs to ‘git@git.eqi.cc:mobile/wang_iOS.git’
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
[/cc]
分析:hint: Updates were rejected because a pushed branch tip is behind its remote 远程仓库的分支比本地的代码要新所以远程的repository和本地的repository冲突。没有pull…
解答:

// 1.首先先pull到本地(避免下面一步覆盖远程)
  git pull origin develop
// 2. 强制push到远程(谨慎覆盖远程)
 git push -u origin develop -f

3)git push时出现的问题
[cc lang=’c’]
warning: push.default is unset; its implicit value has changed in
Git 2.0 from ‘matching’ to ‘simple’. To squelch this message
and maintain the traditional behavior, use:

git config –global push.default matching

To squelch this message and adopt the new behavior now, use:

git config –global push.default simple

When push.default is set to ‘matching’, git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative ‘simple’
behavior, which only pushes the current branch to the corresponding
remote branch that ‘git pull’ uses to update the current branch.

See ‘git help config’ and search for ‘push.default’ for further information.
(the ‘simple’ mode was introduced in Git 1.7.11. Use the similar mode
‘current’ instead of ‘simple’ if you sometimes use older versions of Git)

fatal: The current branch Develop has no upstream branch.
To push the current branch and set the remote as upstream, use

git push –set-upstream origin Develop
[/cc]

解: 情况:在本地用clone了一份代码~ 这个项目是第一次提交~ 直接用的git push(没有指定分支)
看git给的提示 git config –global push.default matching
push.default包含nothing(不push任何分支), matching (本地分支和服务器匹配), upstream(当前分支push到upstream分支), simple(当前分支push到upstream分支上,名字不匹配拒绝,git2.0+默认 安全), current(将当前分支push到同名分支)这五个值
4.error: You have not concluded your merge
[cc]
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.
[/cc]
解:保留本地 git merge –abort

5.添加.gitignore不起作用
[cc lang=’c’]
.DS_Store
.Trashes

DerivedData/
build/
xcuserdata/

*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xccheckout
*.xcuserdatad
*.moved-aside
*.swp
*.lock
*~.nib

!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3

#CocoaPods
*.xcworkspace/
Pods/

fastlane/report.xml
fastlane/screenshots
[/cc]
解决办法:删除cache(***为项目名字)
[cc lang=’c’]
git rm –cached ***.xcodeproj/project.xcworkspace/xcuserdata/***.xcuserdatad/UserInterfaceState.xcuserstate
[/cc]


继续更新中..

发表回复

电子邮件地址不会被公开。 必填项已用*标注