回答編集履歴
1
Add expression
test
CHANGED
@@ -1,3 +1,181 @@
|
|
1
1
|
a ファイルをファイルとして追加しただけで、 Git 管理に追加していなければ、
|
2
2
|
|
3
3
|
通常の `stash` コマンドではファイルは `stash` 領域に待避されません
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
## 実験
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
Git 管理に追加されていないファイルは
|
12
|
+
|
13
|
+
`stash` しても `stash` 領域に待避されません:
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```console
|
18
|
+
|
19
|
+
$ git status
|
20
|
+
|
21
|
+
On branch master
|
22
|
+
|
23
|
+
Untracked files:
|
24
|
+
|
25
|
+
(use "git add <file>..." to include in what will be committed)
|
26
|
+
|
27
|
+
test.txt
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
nothing added to commit but untracked files present (use "git add" to track)
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
$ git stash
|
36
|
+
|
37
|
+
No local changes to save
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
$ git status
|
42
|
+
|
43
|
+
On branch master
|
44
|
+
|
45
|
+
Untracked files:
|
46
|
+
|
47
|
+
(use "git add <file>..." to include in what will be committed)
|
48
|
+
|
49
|
+
test.txt
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
nothing added to commit but untracked files present (use "git add" to track)
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Git 管理に追加すると `stash` は成功します:
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
```console
|
64
|
+
|
65
|
+
$ git add test.txt
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
$ git stash
|
70
|
+
|
71
|
+
Saved working directory and index state WIP on master: 68829db First commit
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
$ git status
|
76
|
+
|
77
|
+
On branch master
|
78
|
+
|
79
|
+
nothing to commit, working tree clean
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
$ git stash list
|
84
|
+
|
85
|
+
stash@{0}: WIP on master: 68829db First commit
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
$ git stash show 0
|
90
|
+
|
91
|
+
test.txt | 1 +
|
92
|
+
|
93
|
+
1 file changed, 1 insertion(+)
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
この場合は `checkout` してもファイルはワーキングツリーではなく
|
100
|
+
|
101
|
+
`stash` 領域に存在します:
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
```console
|
106
|
+
|
107
|
+
$ git checkout -b feature
|
108
|
+
|
109
|
+
Switched to a new branch 'feature'
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
$ git status
|
114
|
+
|
115
|
+
On branch feature
|
116
|
+
|
117
|
+
nothing to commit, working tree clean
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
$ git stash list
|
122
|
+
|
123
|
+
stash@{0}: WIP on master: 68829db First commit
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
$ git stash show 0
|
128
|
+
|
129
|
+
test.txt | 1 +
|
130
|
+
|
131
|
+
1 file changed, 1 insertion(+)
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
もし、Git 管理されていないファイルがワーキングツリーにある状態で `checkout` が成功すると、
|
138
|
+
|
139
|
+
ファイルはワーキングツリーに残ったままになります:
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
```console
|
144
|
+
|
145
|
+
$ git status
|
146
|
+
|
147
|
+
On branch master
|
148
|
+
|
149
|
+
Untracked files:
|
150
|
+
|
151
|
+
(use "git add <file>..." to include in what will be committed)
|
152
|
+
|
153
|
+
test.txt
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
nothing added to commit but untracked files present (use "git add" to track)
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
$ git checkout -b feature
|
162
|
+
|
163
|
+
Switched to a new branch 'feature'
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
$ git status
|
168
|
+
|
169
|
+
On branch feature
|
170
|
+
|
171
|
+
Untracked files:
|
172
|
+
|
173
|
+
(use "git add <file>..." to include in what will be committed)
|
174
|
+
|
175
|
+
test.txt
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
nothing added to commit but untracked files present (use "git add" to track)
|
180
|
+
|
181
|
+
```
|