美文网首页我的iOS世界
XCode某个文件被物理删除了git恢复方法

XCode某个文件被物理删除了git恢复方法

作者: ldhonline | 来源:发表于2018-04-19 11:48 被阅读0次

一、场景

在XCode的项目树中删除一个文件,不小心点了 Move to Trash。


21849D98-1920-498B-A67F-27FA88ED6943.png

这样这个文件就被物理删除了,还好有 git 大法

二、先看 git status

MyMac:coyote_assistant liudh$ git status
On branch feature_***_ldh
Your branch is up-to-date with 'origin/feature_***_liudh'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    "***********************.m"

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   ***********************/project.pbxproj
    modified:   ***********************/contents.xcworkspacedata
    modified:   ***********************.xcworkspace/xcuserdata/shuw.xcuserdatad/UserInterfaceState.xcuserstate
    modified:   ***********************/xcdebugger/Breakpoints_v2.xcbkptlist
    modified:   ***********************.m
    modified:   ***********************.h
    modified:   ***********************.m
    .....
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    *** 2018-04-18 14-30-08/

绿色文字就是删除的记录,git其实自带智能提示,上面那一行就是恢复的命令

(use "git reset HEAD <file>..." to unstage)

1、从上一个版本恢复

// 文件名已隐藏,请使用真实文件名
git reset HEAD ******---.m 

执行完后,发现deleted信息已不见了

2、重新迁入文件

git checkout --  .....m 

发现文件回来了。

相关文章

  • XCode某个文件被物理删除了git恢复方法

    一、场景 在XCode的项目树中删除一个文件,不小心点了 Move to Trash。 这样这个文件就被物理删除了...

  • git checkout

    git checkout xxbranch 切换到某个分支git checkout file 恢复文件

  • git7~git还原文件到某个版本

    2019.05.10 git还原某个文件到某个版本 git log test.php 找到要恢复的hash git...

  • git 撤销

    恢复暂存区的指定文件到工作区 $ git checkout [file] 恢复某个commit的指定文件到暂存区和...

  • git 撤销

    恢复暂存区的指定文件到工作区 $ git checkout [file] 恢复某个commit的指定文件到暂存区和...

  • Git恢复某个删除的文件

    找到需要删除的文件所在的版本,然后找到该版本的上一个版本的hash执行git checkout 版本hash 文件...

  • RDS MySQL 物理备份文件恢复到自建数据库

    RDS MySQL 物理备份文件恢复到自建数据库 RDS 5.7的物理备份恢复到本地的方法 mysql 备份工具 ...

  • 撤销

    恢复暂存区的指定文件到工作区 git checkout file 恢复某个commit的执行文件到暂存区和工作区 ...

  • git修改远程仓库地址

    git修改远程仓库地址 git 方法有三种: 修改命令 先删后加 直接修改config文件

  • Git的使用场景

    以此文记述工作中遇到的Git问题,及其解决方法。 恢复被同事误删的文件 场景:同事认为文件 useful.js 在...

网友评论

    本文标题:XCode某个文件被物理删除了git恢复方法

    本文链接:https://www.haomeiwen.com/subject/ygtwkftx.html