git 或 vscode存储未跟踪的代码,恢复时报错 git stash save -a 引发的 Could not restore untracked files from stash 问题

1.查找stash commit id
git log --graph --all --decorate --oneline

– graph意思是以图形的模式显示分支,

–all意思是显示所有的commit记录,

–decorate参数用来显示一些相关的信息,如HEAD、分支名、tag名等,

–oneline就是一个commit只显示一行

执行后如下面:

- 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

2.切换到该分支

切换到你想恢复的记录,记住前面的id

git checkout 第一步查找出的commitid
3.reset 该commitid
git reset HEAD~1
4.保存修改到stash中
git stash
5.切换到之前的分支
git checkout 分支名称
6.pop stash即可
git stash apply
// 或者
git stash pop
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值