-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathgit-emacs.muse
340 lines (216 loc) · 9.09 KB
/
git-emacs.muse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#created 2008-03-23 [22:34]
#date 2008-03-24 [21:24]
#title A Guided Tour of emacs-git
#author TSKim
<contents>
* Installation
- [[./git-emacs-1.0.tar.gz][Download git-emacs-1.0.tar.gz]]
- [[./git-emacs.el.html][git-emacs.el]]/[[./git-emacs.el][raw]]
- [[./git-modeline.el.html][git-modeline.el]]/[[./git-modeline.el][raw]]
- [[./git-blame.el.html][git-blame.el]]/[[./git-blame.el][raw]]
<src lang="emacs-lisp">
(add-to-list 'load-path "/home/tsgates/Skills/git/git-emacs-1.0")
(require 'git-emacs)
</src>
* Configuration
[[./config-init.png][git-config-init command]]
[[./config-init2.png][Automatically set current user.name & user.email]]
- Set _user.name_ & _user.email_ if it is not set yet
- But, git-emacs recommends the _full name_ and _email address_ of the _user logged in_
* Cloning
** 1. Run 'git-clone'
[[./clone0.png][Run 'git-clone']]
- Run 'git-clone'
** 2. Select local directory
[[./clone1.png][Move directory]]
[[./clone2.png][Select the directory to be cloned]]
- With *'ido'* interface, you can change directory
- Create directory with *'C-m'* (*'M-n'*, *'M-p'* to search history, reference to *'ido'*)
** 3. Select repository
[[./clone3.png][Select repository]]
- Select repositories from _history_ and your _bookmarks_ or type new one
** 4. All things done
[[./clone4.png][Start to clone from repository]]
[[./clone5.png][All things done]]
- Support _asynchronous_ downloading from the repository
- All things ok, you can see message *"Cloned"*!
* Importing
** 1. run 'git-init-from-archive'
[[./init-archive1.png][Init from archive]]
- Run 'git-init-from-archive'
** 2. Select archive file
[[./init-archive2.png][Selecting archive file]]
- Select the project file
- And then create git repository
** 3. If necessary, set config user.name and user.email
[[./init-archive3.png][Then, setting config user.name and user.email]]
- It comes from OS user information
** 4. Initial commit
[[./init-archive4.png][Inital commit log]]
- *'C-cC-c'* to actually commit the revisions
** 5. Commited result
[[./init-archive5.png][After commiting]]
* Making changes
** 1. Open the file which is under the git
[[./commit1.png][Open the file]]
- The **green** dot in the modeline indicates the state of this source file is _uptodate_
(**gray** : _unknown_, **tomato** : _modified_, **red** : _deleted_, **purple** : _unmerged_)
- As you saw in the *modeline*, *'vc-git'* is still working also
** 2. Editing sources and saving the changes
[[./commit2.png][After saving the changes]]
- After saving the changes, the state of the file also change from _uptodate_ to _modified_
(**tomato** dot in the modeline)
** 3. Commit your changes with **'C-x v v'** key or **'git-commit-all'**
[[./commit3.png][Commit your changes after editing log]]
- Of course **'C-x v v'** key is well-known ***'next action'*** in *vc-mode* in emacs
- It works depending on the state of the file you are editing
("_modified_ -> commmit" & "_unmerged_ -> merge" & "_unknown_ -> add", etc)
- Edit your log and then press *'C-c C-c'* in ***git-log*** buffer
** 4. All things done
[[./commit4.png][After commit]]
- The state of the buffer turns to _uptodate_ also
* Viewing project history
** 1. Run 'git-history' for project or 'git-log' for each file
[[./history1.png][History view]]
- Run *'git-history'*
** 2. 'vc-log' history browser with fancy color
[[./history2.png][History browsing]]
- Actually, it is *'vc-log'* with fancy *advises*
- *'p'*, *'n'* with a convenient per log up/down moving
- *'q'* with a simple quit
* Managing Branches
** 1. Show branchs with 'git-branch'
[[./branch1.png][Display branch list]]
- Since we did not create any buffers, we are simply in the ***master*** branch (marked with a asterisk, '*')
- If you want simply checkout only, run *'git-checkout'* instead
** 2. Create new branch with 'c' in *git-branch* buffer
[[./branch2.png][After pressing 'c', input the new name of the branch]]
- run *'git-create-branch'* or *'git-checkout-to-new-branch'* if you are not in ***'git branch'*** buffer
** 3. Select the base branch
[[./branch3.png][Select the branch you want to base on]]
- Only **master** branch exists
** 4. All things done
[[./branch4.png][Reload current buffer]]
[[./branch5.png][Check see if switched to the new branch]]
- Everything seems to be fine, and *modeline* in the "test.c" also changed to *'new-branch'*!
** 5. Topic : Switch to other branch
[[./branch6.png][Switch to other branch after selecting branch]]
[[./branch7.png][Generate automatic commit log]]
[[./branch8.png][Finally switched to 'mater']]
- With a *'RET'* key in **'git-branch'**, you can switch to selected other branch
- If this buffer is not _uptodate_, commit with a _automatically generated log_
** 6. Topic : Delete branches
[[./branch9.png][Delete 'new-branch' in 'git-branch']]
[[./branch10.png][Finally delete a 'new-branch']]
- Isn't it simple?
** 7. Topic : gitk
[[./branch11.png][Launching gitk in emacs]]
- Run *gitk* with a *'gitk'* command in the buffer!
* Tagging
** 1. Create new tag 'git-tag' or 'git-snapshot'
[[./tag1.png][Create new tag]]
- Run *'git-tag'* or *'git-snapshot'*
** 2. Input the tag
[[./tag2.png][Input tag name]]
- Input new tag name
** 3. All things done
[[./tag3.png][All things done]]
- ok
** 4. Checking out
[[./tag4.png][Checking out]]
[[./tag5.png][Checking out to new branch]]
- Checking out may cause the branch to be dangle
- Better to checkout to new branch
** 5. Checking out to new branch
[[./tag6.png][Checking out to new branch]]
[[./tag7.png][Input the new branch name]]
[[./tag8.png][Based on what?]]
[[./tag9.png][Ok on new 'wild-idea' branch]]
- You can make new branch based on tags and other branches!
* Diffing
** 1. Run 'git-diff'
[[./diff1.png][Run 'git-diff']]
- Run 'git-diff'
** 2. Select diffing target
[[./diff2.png][Select diffing target]]
- Select the target
** 3. Select diffing revision
[[./diff3.png][Select revision]]
- **HEAD** means diffing against _HEAD_ vs _cached file_ you selected at step 2
- **HEAD~2** means diffing against _second parent of HEAD_ (referencing to git manual)
** 4. Ediff
[[./diff4.png][Diffing with ediff]]
[[./diff5.png][Diffing against HEAD~2]]
- Move with *'p'*, *'n'* keys to the next/previous different region
- Of course *'q'* to quit and restore previous windows
* Merging
** 1. Try to merge from other branch with 'git-merge'
[[./merge1.png][Run 'git-merge']]
- Run 'git-merge'
** 2. Select target branch
[[./merge2.png][Select the branch to be merged]]
- In *'git-merge'*, you can easily select with a *'ido'* interface you may be familiar
** 3. After merge
[[./merge3.png][After merge, it will launch git-status mode]]
- As you see in above, there is a _conflict_ in 'test.c'
- Try to resolve conflict(merged) with *'!'* key
** 4. 3 way merge
[[./merge4.png][3 way merge similar to famous 'psvn.el']]
- ediff-merge works fantastically
** 5. After resolving conflicts
[[./merge5.png][Return to the merged 'test.c']]
- But, as you know, you have to commit to reflect your changes with *'C-x v v'*
(_purple_ dot in modeline indicates 'test.c' is unmerged(conflict))
- _Submit the commit log_ to complete the job
* Checking the status of the project
** Run 'git-status'
[[./status1.png][Git cloned directory right after cloning]]
- Display current status of tree!
- *'m'*, *'u'* for selecting(marking) and unselecting and *'SPACE'* to toggle mark
** Inspecting Directory
[[./status4.png][Expanding tree or open file]]
- *'q'* : quit status mode
- *'RET'* : open file/expand tree
- *'v'* : view file
- *'n'* : next item
- *'p'* : previous item
- *'N'* : next meaningful item
- *'P'* : previous meaningful item
- '<' : first item
- '>' : last item
- 'g' : refresh
- *'='* : diffing (ref.Diffing)
- *'!'* : resolving conflict (ref.Merging)
- *'k'* : gitk (ref. gitk)
** Naive command on git with '.'
[[./status5.png][Git naive command]]
- *'.'* : git command
** Rename with 'r'
[[./status7.png][Rename on marks or current item]]
[[./status8.png][After renaming all!]]
- You can see the _newly added_ test2.c
- In order to reflect the changes the repository, commit!
** Marking with '*'
[[./regexp-select1.png][Regular expression marking]]
[[./regexp-select2.png][After marking with regexp "RegNotes.*"]]
- Support regular expression marking with '*'
** Deleting with 'd'
[[./delete1.png][Delete the selected files]]
[[./delete2.png][After deleting]]
- Select the files to be deleted with *'d'*
** Add .gitignore with 'i'
[[./status-ignore.png][Select files you want to ignore]]
[[./status-ignore1.png][After ignoring]]
- _Select the files_ that you want to ignore
- Add the selected files or ask you the pattern to be ignored
** Switching branch with 'b'
[[./status2.png][Switching branch]]
[[./status3.png][After switching branch]]
- You can switch to other branch with 'b' key
** Sarcastic blame! with '?'
[[./status6.png][Open in blame mode]]
- Git blame! from official git-blame.el(David Kågedal)
** Summary mode with 's'
[[./status-summary.png][Summary the view]]
- Summary with *'Occur'*
- Iterate with 'next-error and 'previous-error key binding