#!/bin/bash
# READ ME:
# Please run `git init` if you don't
# init yet before run this script file
# C1--C2--C3--C6--C7 <- topic
# \ \ /
# \ C4--C5
# \
# C8--C9 <- master
#
# `topic` rebase to `master`
let cm=0 # (commit)
let fc=0 # (file count)
# C1 (master, topic)
let cm++; let fc++; touch "file$fc";
git add "file$fc"; git commit -m "C$cm"
git branch topic
# C2 (topic, temp)
git checkout topic
let cm++; let fc++; touch "file$fc";
git add "file$fc"; git commit -m "C$cm"
git branch temp
# C3
let cm++; let fc++; touch "file$fc";
git add "file$fc"; git commit -m "C$cm"
# C4-5
git checkout temp
let cm++; let fc++; touch "file$fc";
git add "file$fc"; git commit -m "C$cm"
let cm++; let fc++; touch "file$fc";
git add "file$fc"; git commit -m "C$cm"
# C6
git checkout topic
let cm++
git merge -m "C$cm" temp
git branch -d temp
# C7
let cm++; let fc++; touch "file$fc";
git add "file$fc"; git commit -m "C$cm"
# C8-9
git checkout master
let cm++; let fc++; touch "file$fc";
git add "file$fc"; git commit -m "C$cm"
let cm++; let fc++; touch "file$fc";
git add "file$fc"; git commit -m "C$cm"
#####
echo -e "\n## Before:"
git log --all --decorate --oneline --graph --pretty="format:%s%d"
echo -e "\n## In:"
git checkout topic
git rebase master
echo -e "\n## After:"
git log --all --decorate --oneline --graph --pretty="format:%s%d"
Standard input is empty
## Before: ## In: ## After:
touch: cannot touch 'file1': Permission denied ./prog.sh: line 20: git: command not found ./prog.sh: line 20: git: command not found ./prog.sh: line 21: git: command not found ./prog.sh: line 24: git: command not found touch: cannot touch 'file2': Permission denied ./prog.sh: line 27: git: command not found ./prog.sh: line 27: git: command not found ./prog.sh: line 28: git: command not found touch: cannot touch 'file3': Permission denied ./prog.sh: line 32: git: command not found ./prog.sh: line 32: git: command not found ./prog.sh: line 35: git: command not found touch: cannot touch 'file4': Permission denied ./prog.sh: line 38: git: command not found ./prog.sh: line 38: git: command not found touch: cannot touch 'file5': Permission denied ./prog.sh: line 41: git: command not found ./prog.sh: line 41: git: command not found ./prog.sh: line 44: git: command not found ./prog.sh: line 46: git: command not found ./prog.sh: line 47: git: command not found touch: cannot touch 'file6': Permission denied ./prog.sh: line 51: git: command not found ./prog.sh: line 51: git: command not found ./prog.sh: line 54: git: command not found touch: cannot touch 'file7': Permission denied ./prog.sh: line 57: git: command not found ./prog.sh: line 57: git: command not found touch: cannot touch 'file8': Permission denied ./prog.sh: line 60: git: command not found ./prog.sh: line 60: git: command not found ./prog.sh: line 64: git: command not found ./prog.sh: line 67: git: command not found ./prog.sh: line 68: git: command not found ./prog.sh: line 71: git: command not found