F:\originCloneTolocal\gitskill>git stash //这里因为工作空间或者暂存区没有修改,所以无法保存
No local changes to save
F:\originCloneTolocal\gitskill>git stash list
F:\originCloneTolocal\gitskill>git stash //第一次保存现场
Saved working directory and index state WIP on feature1: 3ad4a09 Branch feature:
sercond changes
HEAD is now at 3ad4a09 Branch feature: sercond changes
F:\originCloneTolocal\gitskill>git stash list
stash@{0}: WIP on feature1: 3ad4a09 Branch feature: sercond changes
F:\originCloneTolocal\gitskill>git stash apply //恢复现场
On branch feature1
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: test2.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
gg
no changes added to commit (use "git add" and/or "git commit -a")
F:\originCloneTolocal\gitskill>git stash list
stash@{0}: WIP on feature1: 3ad4a09 Branch feature: sercond changes
F:\originCloneTolocal\gitskill>git stash //在保存一次
Saved working directory and index state WIP on feature1: 3ad4a09 Branch feature:
sercond changes
HEAD is now at 3ad4a09 Branch feature: sercond changes
F:\originCloneTolocal\gitskill>git stash list
stash@{0}: WIP on feature1: 3ad4a09 Branch feature: sercond changes
stash@{1}: WIP on feature1: 3ad4a09 Branch feature: sercond changes
F:\originCloneTolocal\gitskill>git checkout one //切换分支,尝试看看stash如何标号
Switched to branch 'one'
F:\originCloneTolocal\gitskill>git stash
No local changes to save
F:\originCloneTolocal\gitskill>git stash
Saved working directory and index state WIP on one: 5598131 Branch one: add a li
ne
HEAD is now at 5598131 Branch one: add a line
F:\originCloneTolocal\gitskill>git stash list //可以看见最近现场一定为stash@{0}
stash@{0}: WIP on one: 5598131 Branch one: add a line
stash@{1}: WIP on feature1: 3ad4a09 Branch feature: sercond changes
stash@{2}: WIP on feature1: 3ad4a09 Branch feature: sercond changes
F:\originCloneTolocal\gitskill>git stash apply stash@{2}
warning: Cannot merge binary files: test2.txt (Updated upstream vs. Stashed chan
ges)
Auto-merging test2.txt
CONFLICT (content): Merge conflict in test2.txt
F:\originCloneTolocal\gitskill>git stash drop
Dropped refs/stash@{0} (351a6825b9e6a22e4de79f61af527442884ce46b)
F:\originCloneTolocal\gitskill>git stash list
stash@{0}: WIP on feature1: 3ad4a09 Branch feature: sercond changes
stash@{1}: WIP on feature1: 3ad4a09 Branch feature: sercond changes
F:\originCloneTolocal\gitskill>git stash frop stash@{1} //这里输错了,git 提示很好啊
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 clear
F:\originCloneTolocal\gitskill>git stash drop stash@{1}
Dropped stash@{1} (e0f3f6ed485be14e470ba26b83b99376338f1e3c)
用户7303966659
一个任务期间,接到新任务,这时候需要先完成新任务,但是旧任务依旧在工作区或者暂存区
Q:为什么分支间的的commit 会互相影响
A.工作区和暂存区是所有分支共享,这意味着不同分支间会影响
解决办法:
Example: