$ git init
でディレクトリ以下をgitの管理対象にして
$ git add file
でworking treeからindexに登録
$ git commit
でindexのファイルをHEADへ登録
$ git diff
working treeとindexの差を表示
$ git diff –cached
indexとHEADの差を表示
$ git diff HEAD
working treeとHEADの差を表示
ファイルの差分をみるdiffコマンドを整理してみました
Ubuntu 12.04で試しています
フォルダ構成がこんな感じ時
$ tree
.
├── 1
│ ├── 1.txt
│ ├── 2.txt
│ └── 3.txt
└── 2
├── 1.txt
└── 2.txt
差分を見たい時、
$ diff 1 2
diff 1 2
diff 1/2.txt 2/2.txt
1c1
< 1111
---
> 2222
1 のみに存在: 3.txt
unified形式だと
$ diff -u 1 2
diff -u 1/2.txt 2/2.txt
--- 1/2.txt 2014-10-16 17:11:17.925405481 +0900
+++ 2/2.txt 2014-10-16 17:17:43.965416847 +0900
@@ -1 +1 @@
-1111
+2222
1 のみに存在: 3.txt
で最初の3行がまとめで、それ以降が差です
– が1つ目のディレクトリ、+ が2つ目のディレクトリ
さらにフォルダを追加して
$ tree
.
├── 1
│ ├── 1-1
│ │ └── 1.1.text
│ ├── 1.txt
│ ├── 2.txt
│ └── 3.txt
└── 2
├── 1-1
│ └── 1.1.text
├── 1.txt
└── 2.txt
差分をみます、サブディレクトリも比較するには-rが必要です
$ diff -u -r 1 2
共通のサブディレクトリー: 1/1-1 と 2/1-1
diff -u 1/2.txt 2/2.txt
--- 1/2.txt 2014-10-16 17:41:37.781459066 +0900
+++ 2/2.txt 2014-10-16 17:41:54.381459554 +0900
@@ -1 +1 @@
-1111
+22222
1 のみに存在: 3.txt
user@user-ThinkPad-X120e:~/workspace/diff$ diff -u -r 1 2
diff -u -r 1/1-1/1.1.text 2/1-1/1.1.text
--- 1/1-1/1.1.text 2014-10-16 17:36:31.969450061 +0900
+++ 2/1-1/1.1.text 2014-10-16 17:42:11.921460071 +0900
@@ -1 +1 @@
-1-1
+2-1
diff -u -r 1/2.txt 2/2.txt
--- 1/2.txt 2014-10-16 17:41:37.781459066 +0900
+++ 2/2.txt 2014-10-16 17:41:54.381459554 +0900
@@ -1 +1 @@
-1111
+22222
1 のみに存在: 3.txt
差分をとってあてるには
$ diff -u -r 1 2 > patch.txt
$ mv patch.txt 1/
$ cd 1
$ patch -p1 < patch.txt
patching file 1-1/1.1.text
patching file 2.txt
と、diffの結果をファイルにして、あてたいフォルダへ移動、patchコマンドの-p1が1階層無視するオプションです
差分を適用したいフォルダを1つ目に指定します(今回は1ディレクトリ)
ちょっと大きめのウィジェットを右サイドバーに設置するとはみ出たため全体の横幅を広げました
$ vim wp-content/themes/twentyeleven/style.css
[css]
# page {
max-width: 1000px;
}
[/css]
を大きくすれば大きくなります
ブラウザのキャッシュに気をつけてスーパーリロード(Chromeならshift+F5)したら反映されてました
以前
WordPressにシェアボタンを用意する過程を公開
で、子テーマを作成しましたがPHPの修正が手抜きでした
テーマのアップデートをしたら案の定、修正が飛んでしまったのでやり直し..
フォルダ構成では
wp-content/themes/twentyeleven
wp-content/themes/twentyeleven-child
twentyeleven-childのフォルダに
style.cssをおいて、twentyelevenを継承するようにしたらCSSはOKでした
PHPも同様、同じファイル名で存在させれば子側を読み込みます(function.php以外)
content-single.phpを変更してたので、
アップデートして新しくなったcontent-single.phpをコピー
$ cp wp-content/themes/twentyeleven/content-single.php wp-content/themes/twentyeleven-child/content-single.php
子テーマのcontent-single.phpを修正、でバージョンアップ、かつ、以前の仕様に戻せました
次、アップデートしたら子側は手動アップデートでしょうか..
もっといい方法がある気がします..