$ git stash apply stash@{0}
XXXX already exists, no checkout
error: could not restore untracked files from stash
第一次遇到这种问题,我在分支暂称之为V3.0准备对原框架进行部分升级,但这个只能在其他有空闲的时间去做,所以我就用到了stash,当我有空闲的时候我就进行框架升级改造,当我有开发任务的时候,我就进行正常的业务功能开发,中间只需要进行一次git stash操作,把我的代码进行暂存操作,长期以来一致也没遇到什么问题,知道今天,昨晚发布了新的上线版本。一切OK之后,我在做codereview时,进行了一些代码备注,早上来,想昨晚已经成功发布了v3.0,那么今天就应该是V3.1,于是我就把昨晚发布之后codereview时添加的备注进行了add&commit操作,之后直接在修改缘分支名git branch -m v3.1,我想问题应该在这里,以前使用git checkout -b $newBranch没有遇到过上面的问题,暂且这么认为吧,先把问题解决,毕竟框架升级改造的代码也不少,遗失了将非常可惜。
在网上找了几篇帖子,跟着做没有找到自己想要的,但是却给了我解决问题的思路,首先找到stash@{0}的提交hash:
$ git log --graph --all --decorate --oneline | grep "stash"
| | | * fa0a78a (refs/stash) On v3.0.0.1: updateMap
也就是fa0a78a
然后切换到这里:
$ git checkout fa0a78a
Note: switching to 'fa0a78a'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at fa0a78a On v3.0.0.1: updateMap
ckx0709@ckx MINGW64 /d/Eps/community-health-server ((fa0a78a...))
在这里切出新的分支:
ckx0709@ckx MINGW64 /d/Eps/community-health-server ((fa0a78a...))
$ git checkout -b release_v3.0.0.1_up
Switched to a new branch 'release_v3.0.0.1_up'
ckx0709@ckx MINGW64 /d/Eps/community-health-server (release_v3.0.0.1_up)
再新的分支3.1合并切出来的新分支3.0_up:
$ git merge release_v3.0.0.1_up
Merge made by the 'recursive' strategy.
common/dao.go | 8 ++++++++
common/entity.go | 5 +++++
common/service.go | 32 ++++++++++++++++++++++++++++++++
common/vo.go | 4 ++++
control/visitor_up.go | 9 ++++++---
vo/visitor_up.go | 42 ++++++++++++++++++++++++++++++++++++++++++
6 files changed, 97 insertions(+), 3 deletions(-)
create mode 100644 vo/visitor_up.go
Complete.The code has been retrieved.