Git使いになろう:ファイル内の変更を部分的にコミットする

ひとつのファイルを更新していて、コミットするときに更新の内容を別々の単位でコミットしたくなる場合があります。
このとき、ファイルを編集しなおしてからコミットする必要はありません。git addをする際に”-p”というオプションを付ければよいです。
元のファイル

Ragtimeblues
https://ragtimeblues.net/

に対して

Ragtimeblues
since 2016.01.01
https://ragtimeblues.net/
This site is my diary.

と変更したとします。ここでgit add -pとしてみます。

$ git add -p sample.txt 
diff --git a/sample.txt b/sample.txt
index 1e85400..36f88c3 100644
--- a/sample.txt
+++ b/sample.txt
@@ -1,2 +1,4 @@
 Ragtimeblues
+since 2016.01.01
 https://ragtimeblues.net/
+This site is my diary.
Stage this hunk [y,n,q,a,d,/,s,e,?]? 

このhunk(大きな塊)をステージするかが訊かれます。使い方がわからなければ’?’でヘルプを表示できます。ヘルプを表示してみると、

y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help

となりますのでやりたいことを選択すればOKです。

Emacsの変数の値を一時的に変更する

Emacs上で作業中に変数の値を一時的に変更したい場合は
M-x set-variableを入力します。
ミニバッファに
Set variable:
と表示されますので変数名を入力してEnter。
バッファローカルな変数の値を入力するように表示されますので、値を入力すればよいです。