Created
July 28, 2015 15:25
-
-
Save milan11/2550b31382acd71674fe to your computer and use it in GitHub Desktop.
Git - rebasing a tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -u | |
function init_repo | |
{ | |
git init testrepo | |
cd testrepo | |
} | |
function do_commit | |
{ | |
APPENDED_TEXT="$1" | |
COMMIT_MESSAGE="$1" | |
echo "$APPENDED_TEXT" >> file | |
git add file | |
git commit -m "$COMMIT_MESSAGE" | |
} | |
function fix_merge | |
{ | |
APPENDED_TEXT="$1" | |
COMMIT_MESSAGE="$1" | |
echo "fix_merge_$APPENDED_TEXT" >> file | |
git add file | |
git commit -m "merge_$COMMIT_MESSAGE" | |
} | |
function fix_rebase | |
{ | |
APPENDED_TEXT="$1" | |
echo "fix_rebase_${APPENDED_TEXT}" >> file | |
git add file | |
} | |
init_repo | |
do_commit 1 | |
do_commit 2 | |
git checkout -b a | |
git checkout -b b | |
git checkout -b main | |
do_commit 3 | |
git checkout -b other | |
do_commit 5 | |
do_commit 6 | |
git checkout main | |
do_commit 4 | |
git checkout a | |
do_commit 7 | |
do_commit 8 | |
git checkout b | |
do_commit 9 | |
do_commit 10 | |
git checkout other | |
git merge a || true | |
fix_merge a | |
git merge b || true | |
fix_merge b | |
git rebase main || true | |
fix_rebase 1 | |
git rebase --continue || true | |
fix_rebase 2 | |
git rebase --continue || true | |
fix_rebase 3 | |
git rebase --continue || true | |
fix_rebase 4 | |
git rebase --continue || true | |
fix_rebase 5 | |
git rebase --continue || true | |
fix_rebase 6 | |
git rebase --continue | |
cat file | |
git status | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -u | |
function init_repo | |
{ | |
git init testrepo | |
cd testrepo | |
} | |
function do_commit | |
{ | |
APPENDED_TEXT="$1" | |
COMMIT_MESSAGE="$1" | |
echo "$APPENDED_TEXT" >> file | |
git add file | |
git commit -m "$COMMIT_MESSAGE" | |
} | |
function fix_merge | |
{ | |
APPENDED_TEXT="$1" | |
COMMIT_MESSAGE="$1" | |
echo "fix_merge_$APPENDED_TEXT" >> file | |
git add file | |
git commit -m "merge_$COMMIT_MESSAGE" | |
} | |
function fix_rebase | |
{ | |
APPENDED_TEXT="$1" | |
echo "fix_rebase_${APPENDED_TEXT}" >> file | |
git add file | |
} | |
init_repo | |
do_commit 1 | |
do_commit 2 | |
git checkout -b a | |
git checkout -b b | |
git checkout -b other | |
git checkout -b main | |
do_commit 3 | |
do_commit 4 | |
git checkout other | |
do_commit 5 | |
do_commit 6 | |
git checkout a | |
do_commit 7 | |
do_commit 8 | |
git checkout b | |
do_commit 9 | |
do_commit 10 | |
git checkout other | |
git merge a || true | |
fix_merge a | |
git merge b || true | |
fix_merge b | |
git rebase main || true | |
fix_rebase 1 | |
git rebase --continue || true | |
fix_rebase 2 | |
git rebase --continue || true | |
fix_rebase 3 | |
git rebase --continue || true | |
fix_rebase 4 | |
git rebase --continue || true | |
fix_rebase 5 | |
git rebase --continue || true | |
fix_rebase 6 | |
git rebase --continue | |
cat file | |
git status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment