当前分支进行了修改,但没有commit,此时不能进行切换分支
# Use git stash when you want to record the current state of the working directory and the index,
# but want to go back to a clean working directory.
# The command saves your local modifications away and reverts the working directory to match the HEAD commit.
#将当前的修改贮藏起来,使当前分支回到干净的状态
#Save your local modifications to a new stash entry and roll them back to HEAD (in the working tree and in the index).
git stash
#将贮藏的修改取出来,继续进行功能开发
#Remove a single stashed state from the stash list and apply it on top of the current working tree state.
git stash pop
#Like pop, but do not remove the state from the stash list.
git stash apply
#List the stash entries that you currently have.
git stash list
#Show the changes recorded in the stash entry as a diff between the stashed contents and
#the commit back when the stash entry was first created.
git stash show
#展示每个文件具体的差异内容
git stash show -p
#Remove a single stash entry from the list of stash entries
git stash drop
#Remove all the stash entries
git stash clear
使用了git stash之后,当前分支的当前状态就变干净了
H
is the HEAD commit, I
is a commit that records the state of the index, and W
is a commit that records the state of the working tree.
https://zhuanlan.zhihu.com/p/117553180
https://git-scm.com/docs/git-stash
#查看上一次commit修改了什么内容
git show
#将这个commit应用到当前分支上,实际效果就是当前分支多了一条commit记录
#应用场景:在master分支上提交了一个commit,想在dev分支上也提交一下这个commit,就切到dev分支,然后执行git cherry-pick <commit_id>
git cherry-pick <commit_id>