HeyShinner / Daily

1 stars 1 forks source link

Could not restore untracked files from stash #4

Open HeyShinner opened 4 years ago

HeyShinner commented 4 years ago

git stash -u 之后的事故处理

HeyShinner commented 4 years ago
  1. 查看用法 git stash help
usage: git stash list [<options>]
   or: git stash show [<stash>]
   or: git stash drop [-q|--quiet] [<stash>]
   or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
   or: git stash branch <branchname> [<stash>]
   or: git stash save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
                      [-u|--include-untracked] [-a|--all] [<message>]
   or: git stash [push [--patch] [-k|--[no-]keep-index] [-q|--quiet]
                       [-u|--include-untracked] [-a|--all] [-m <message>]
                       [-- <pathspec>...]]
   or: git stash clear

git stash -u 包含 untracked files

  1. git log --graph --all --decorate --oneline 查看 stash 记录的 commit id
- dd7b26b (master) Extract method
- b0d0487 Rename one of the assertScreenForEvent methods
- ddbb532 Use strong typing for Events
  | *-.   **0374bd1** (refs/stash) WIP on master: d7fe9ab new class Event
  | |\ \  
  | | | * 2a958c1 untracked files on master: d7fe9ab new class Event
  | | * 51510de index on master: d7fe9ab new class Event
  | |/  
  | * d7fe9ab (HEAD) new class Event
  | * c59f0f3 Extract method
  | * 74a987f Rename one of the assertScreenForEvent methods
  | * 75e98b7 Use strong typing for Events
  |/  
  | * 40b5b29 (origin/master, origin/HEAD) added language-chooser

0374bd1 就是出问题的 commit

  1. git checkout 0374bd1
  2. git reset --soft HEAD~1
  3. git stash -u
  4. git checkout <branch_name>
  5. git stash pop

有惊无险,寻回代码 (゚▽゚)/