作業ノート

様々なまとめ、雑感など

小さな習慣を読んだ

小さな習慣

小さな習慣

個人的に習慣化したいことがいくつかあって、色々試していたときにたまたま見つけた本。

小さな習慣とは、より良いことに向かう行動であり、ばかばかしいと思えるほど小さな行動である。

習慣に関する本で他書との違いは、モチベーションに頼らず、とにかく行動を継続することに重点をおいているところ。

モチベーションに頼らないのは、それが信頼できないから。習慣化したい行動にモチベーションを求めない。行動するとモチベーションが得られることはあるが、それはあくまでボーナスとして考える。

行動の継続に重点をおいているのは、それが習慣の本質だから。習慣になるまでは一般的にいわれる21日から30日ではなく、18日から254日としている。つまり習慣になることを目標にすると、習慣化までの期間が広くはっきりしないために、本当に達成したのか判断しにくい。結局、習慣というのは定期的な行動のことなので、毎日続けるためにどうするかを重視したほうがよい。

この点を踏まえたのが小さな習慣。やるべき行動が小さければ、モチベーションに頼らずに毎日実行することができる。また、毎日続けるために自身の生活習慣に合うような形で行動を決める。これは、小さな習慣が万人に向いているということでもある。

読み終えてみると、どうして自分がこういうことに気づかなかったのだろうと思えるくらいに自然であり、当然と感じるような、そういう気づきが得られた本だった。

CentOS 7.2にGraphvizをインストールする

SchemaSpy6のRC1が出ていたので試そうとしたときのこと。

SchemaSpyではGraphvizを使ってリレーションを図示する。6のRC1で実行するとCentOS7.2のgraphvizのバージョン(2.30)では古い、というワーニングが出たので、本家からrpmパッケージをインストールした。

curl -LO http://www.graphviz.org/graphviz-rhel.repo
sudo mv graphviz-rhel.repo /etc/yum.repos.d/graphviz-rhel.repo

repoファイルをダウンロードしてyumのディレクトリに移動する。

sudo yum install \
    graphviz-2.38.0 \
    graphviz-devel-2.38.0 \
    graphviz-gd-2.38.0

パッケージのバージョンを指定しないで実行したところ、2.40をダウンロードしようとして404エラーになったので、ファイルがある最新バージョンを探してインストールした。

参考

gitでトピックブランチをマージ中にリモートブランチが更新されたときの対応

例えば自分の環境で

$ git merge --no-ff feature/add-c

トピックブランチをmasterブランチにマージして

$ git push
error: failed to push some refs to '********'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

pushしても、できなかったときの対応。

$ git fetch
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), done.
From ********
   baf2594..2d4f9f4  master     -> origin/master

fetchしてリモートブランチと同期をとり

$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 2 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean

statusを確認すると、masterブランチとリモートブランチが分岐した状態になっている。

ここでは、自分の環境はトピックブランチ(feature/add-c)をマージした状態で

$ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
*   5361769 - (HEAD -> master) Merge branch 'feature/add-c' (2 minutes ago) <te2u>
|\
| * f3fbe42 - (feature/add-c) add c (3 minutes ago) <te2u>
|/
* baf2594 - add a (17 minutes ago) <te2u>

リモートブランチは別のトピックブランチ(feature/add-b)をマージした状態とする。

$ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative origin/master
*   2d4f9f4 - (origin/master) Merge branch 'feature/add-b' (14 minutes ago) <te2u>
|\
| * ec63e2a - add b (16 minutes ago) <te2u>
|/
* baf2594 - add a (18 minutes ago) <te2u>

メインブランチにトピックブランチ以外のマージを作るのは避けたいのでrebaseしたいところだが、ここで

$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: add c

そのままrebaseすると

$ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
* 0f50808 - (HEAD -> master) add c (23 seconds ago) <te2u>
*   2d4f9f4 - (origin/master) Merge branch 'feature/add-b' (16 minutes ago) <te2u>
|\
| * ec63e2a - add b (18 minutes ago) <te2u>
|/
* baf2594 - add a (20 minutes ago) <te2u>

自分の環境で作成したマージコミットが失われてしまう。

マージコミットが失われないようにするには、rebaseするときに

$ git rebase --preserve-merges origin/master
Successfully rebased and updated refs/heads/master.

preserve-mergesオプションをつけて実行する。こうすると

$ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
*   93ab538 - (HEAD -> master) Merge branch 'feature/add-c' (11 seconds ago) <te2u>
|\
| * d3dedd9 - add c (11 seconds ago) <te2u>
|/
*   2d4f9f4 - (origin/master) Merge branch 'feature/add-b' (19 minutes ago) <te2u>
|\
| * ec63e2a - add b (20 minutes ago) <te2u>
|/
* baf2594 - add a (22 minutes ago) <te2u>

リモートブランチのHEADに、自分の環境でマージしたときのブランチが残った形で適用される。あとは

$ git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 317 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To ********
   d8219f9..2bb1372  master -> master

pushして、リモートブランチを更新する。