xcode commit时,
提示本地已经不是最新的
和服务器中不是最新的
然后导致了:
xcode把代码commit到本地了
然后去命令行中:
licrifandeMacBook-Pro:SalesAppiOS crifan$ git status
On branch master
Your branch is ahead of ‘origin/master’ by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
licrifandeMacBook-Pro:SalesAppiOS crifan$ git push
To http://git.oschina.net/QorosSalesApp/SalesAppiOS
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘http://git.oschina.net/QorosSalesApp/SalesAppiOS’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
licrifandeMacBook-Pro:SalesAppiOS crifan$
git pull
然后让输入注释:
licrifandeMacBook-Pro:SalesAppiOS crifan$ git pull
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
From http://git.oschina.net/QorosSalesApp/SalesAppiOS
4a4d7db..02e52d2 master -> origin/master
Merge made by the ‘recursive’ strategy.
SalesApp/Customer.swift | 32 ++++++++++++++++++++++++-
SalesApp/CustomerTableViewCell.swift | 35 ++++++++++++++++++++——–
SalesApp/CustomerTableViewHeadView.swift | 17 ++++++++++++++
SalesApp/CustomerViewController.swift | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++—————
4 files changed, 155 insertions(+), 29 deletions(-)
licrifandeMacBook-Pro:SalesAppiOS crifan$ git status
On branch master
Your branch is ahead of ‘origin/master’ by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
licrifandeMacBook-Pro:SalesAppiOS crifan$ git push
Counting objects: 32, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (32/32), done.
Writing objects: 100% (32/32), 22.10 KiB | 0 bytes/s, done.
Total 32 (delta 25), reused 0 (delta 0)
To http://git.oschina.net/QorosSalesApp/SalesAppiOS
02e52d2..24a0e66 master -> master
licrifandeMacBook-Pro:SalesAppiOS crifan$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean
licrifandeMacBook-Pro:SalesAppiOS crifan$
终于可以了:
[总结]
当不小心,在未更新服务器上的最新代码,就去
(在Xcode中commit,且勾选了 提交到remote origin/master的话)
,则对应的解决办法是:
回到命令行中:
1.
git pull
会打开vi,其让你输入提交的注释
按i键,进入编辑模式
输入对应的注释
完毕后,按ESC,回到普通模式
输入:wq
表示保存和退出
即可。
2.
git push
把本地的,合并后的更新,上传到远端服务器中。
转载请注明:在路上 » [已解决]Xcode中git的commit失败后命令行提示:Your branch is ahead of ‘origin/master’ by 1 commit