开发技巧-Git
git stash 用法总结
(1)git stash save "save message" : 执行存储时,添加备注,方便查找,只有git stash 也要可以的,但查找时不方便识别。
$ git stash save "one"
$ git stash save "two"
(2)git stash list :查看stash了哪些存储
$ git stash list
stash@{0}: On develop-20211012-V1.0.2-SuZhouBus: two
stash@{1}: On develop-20230414-v1.1.0: one
(3)git stash show :显示做了哪些改动,默认show第一个存储,如果要显示其他存贮,后面加stash@{$num},比如第二个 git stash show stash@{1}
$ git stash show
src/store/modules/app.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
$ git stash show stash@{1}
src/store/modules/app.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(4)git stash show -p : 显示第一个存储的改动,如果想显示其他存存储,命令:git stash show stash@{$num} -p ,比如第二个:git stash show stash@{1} -p
$ git stash show -p
diff --git a/src/store/modules/app.js b/src/store/modules/app.js
index 8a5f055..fc4902c 100644
--- a/src/store/modules/app.js
+++ b/src/store/modules/app.js
@@ -11,7 +11,7 @@ const state = {
device: 'desktop',
isIE: isIE()
}
-
+console.log('我是苏州公交的修改');
const mutations = {
TOGGLE_SIDEBAR: state => {
state.sidebar.opened = !state.sidebar.opened
$ git stash show stash@{1} -p
diff --git a/src/store/modules/app.js b/src/store/modules/app.js
index 8a5f055..2f93016 100644
--- a/src/store/modules/app.js
+++ b/src/store/modules/app.js
@@ -11,7 +11,7 @@ const state = {
device: 'desktop',
isIE: isIE()
}
-
+console.log('我是基线的修改');
const mutations = {
TOGGLE_SIDEBAR: state => {
state.sidebar.opened = !state.sidebar.opened
(5)git stash apply :应用某个存储,但不会把存储从存储列表中删除,默认使用第一个存储,即stash@{0},如果要使用其他个,git stash apply stash@{$num} , 比如第二个:git stash apply stash@{1}
$ git stash apply
On branch develop-20211012-V1.0.2-SuZhouBus
Your branch is up to date with 'origin/develop-20211012-V1.0.2-SuZhouBus'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/store/modules/app.js
no changes added to commit (use "git add" and/or "git commit -a")
$ git stash apply stash@{1}
On branch develop-20211012-V1.0.2-SuZhouBus
Your branch is up to date with 'origin/develop-20211012-V1.0.2-SuZhouBus'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/store/modules/app.js
no changes added to commit (use "git add" and/or "git commit -a")
(6)git stash pop :命令恢复之前缓存的工作目录,将缓存堆栈中的对应stash删除,并将对应修改应用到当前的工作目录下,默认为第一个stash,即stash@{0},如果要应用并删除其他stash,命令:git stash pop stash@{$num} ,比如应用并删除第二个:git stash pop stash@{1}
$ git stash pop
On branch develop-20211012-V1.0.2-SuZhouBus
Your branch is up to date with 'origin/develop-20211012-V1.0.2-SuZhouBus'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/store/modules/app.js
no changes added to commit (use "git add" and/or "git commit -a")
$ git stash pop stash@{1}
On branch develop-20230414-v1.1.0
Your branch is up to date with 'origin/develop-20230414-v1.1.0'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/store/modules/app.js
no changes added to commit (use "git add" and/or "git commit -a")
Dropped stash@{1} (7003049680892963ac488ffb7a8c551b5b003400)
(7)git stash drop stash@{$num} :丢弃stash@{$num}存储,从列表中删除这个存储
(8)git stash clear :删除所有缓存的stash
参考链接: www.cnblogs.com/zndxall/arc…