天天看点

[IOS][git]使用XCODE9时使用git commit导致代码丢失问题

最近新上手xcode9,发现多了一个git navigation的功能,新UI对git功能的展示比较直观,但是使用过程中发现有些比较严重的问题:代码提交后会丢失,在navigation里面找不到最新commit的name。

解决办法:后来直接使用控制台通过git命令来操作,使用git log可以找到navigation里面没有显示的提交,证明git已经接收了提交。然后我们使用命令

git branch//查找branch      
git checkout <branch-name>      

 来checkout之前的分支,会有提示

Warning: you are leaving 5 commits behind, not connected to
any of your branches:

  35a3711 test why not store git info
  b4701b6 test
  af4dd58 1
  c87be34 12
  1c3e92b wifi interference btn

If you want to keep them by creating a new branch, this may be a good time
to do so with:

 git branch <new-branch-name> 35a3711      

 这时候只需要根据提示创建一个新的分支,就可以找回丢失的commit了。