LoginSignup
1
1

More than 3 years have passed since last update.

年齢の commit graph 作成スクリプト(git merge --no-ff の説明用)

Last updated at Posted at 2020-08-02

先日投稿した記事( Gitで急いで戻したいならmerge --no-ffを使う )でご紹介した、年齢のcommit graphを作成するスクリプトです

スクリプト

c.sh
#!/bin/sh

git init
echo '0歳' > a.txt
git add a.txt
git commit -a -m '0歳'
git tag -a age0 -m '0歳'

# 0歳に戻ります

git checkout master
git reset --hard age0
#git log --oneline --graph

# non fast-forward のcommit graphを作ります

git checkout -b youjiki master
echo '1歳' > a.txt; git commit -a -m '1歳'
echo '2歳' > a.txt; git commit -a -m '2歳'
echo '3歳' > a.txt; git commit -a -m '3歳'

git checkout master
git merge --no-ff youjiki -m '幼児期のおわり'
#git log --oneline --graph

git checkout -b youchien master
echo '4歳' > a.txt; git commit -a -m '4歳'
echo '5歳' > a.txt; git commit -a -m '5歳'
echo '6歳' > a.txt; git commit -a -m '6歳'

git checkout master
git merge --no-ff youchien -m '幼稚園卒園'
git log --oneline --graph

# 0歳に戻ります

git checkout master
git reset --hard age0
git branch -D youjiki
git branch -D youchien
#git log --oneline --graph

# fast-forward のcommit graphを作ります

git checkout -b youjiki2 master
echo '1歳' > a.txt; git commit -a -m '1歳'
echo '2歳' > a.txt; git commit -a -m '2歳'
echo '3歳' > a.txt; git commit -a -m '3歳'

git checkout master
git merge --ff youjiki2 -m '幼児期のおわり'
#git log --oneline --graph

git checkout -b youchien2 master
echo '4歳' > a.txt; git commit -a -m '4歳'
echo '5歳' > a.txt; git commit -a -m '5歳'
echo '6歳' > a.txt; git commit -a -m '6歳'

git checkout master
git merge --ff youchien2 -m '幼稚園卒園'
git log --oneline --graph

git branch -D youjiki2
git branch -D youchien2

実行結果

git merge --no-ff のグラフ

*   fa6cf7c (HEAD -> master) 幼稚園卒園
|\
| * 0b9ffb0 (youchien) 6歳
| * 74a3283 5歳
| * 9dfb758 4歳
|/
*   aace58b 幼児期のおわり
|\
| * 6e848f8 (youjiki) 3歳
| * 0edd54f 2歳
| * d979b3a 1歳
|/
* 798a893 (tag: age0) 0歳

git merge --ff のグラフ

* d35dd2e (HEAD -> master, youchien2) 6歳
* f758c86 5歳
* ceddede 4歳
* 88e1396 (youjiki2) 3歳
* be9c037 2歳
* 6b0691a 1歳
* 798a893 (tag: age0) 0歳

使い方

  • 適当なディレクトリに設置して
  • 下記スクリプトをコピペして
  • 保存し
  • 実行してください
% mkdir agegraph
% cd agegraph
% vim c.sh
% sh c.sh

毎回手動で作るとけっこう大変だったので、もしよかったらご利用くださいませ。
元の記事は( Gitで急いで戻したいならmerge --no-ffを使う )です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1