Last active
January 29, 2016 17:35
-
-
Save anatolyborodin/6505a364a68584f13846 to your computer and use it in GitHub Desktop.
git filter-branch bug
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/sh | |
set -e | |
GIT=git | |
message() | |
{ | |
echo | |
echo "${1}" | |
echo "----------------------------------------" | |
} | |
init_repo() | |
{ | |
$GIT init | |
echo aaa > a.txt && $GIT add a.txt && $GIT commit -a -m a | |
echo bbb > a.txt && $GIT add a.txt && $GIT commit -a -m b | |
echo ccc > a.txt && $GIT add a.txt && $GIT commit -a -m c | |
} | |
# test `git replace` and git `filter-branch` | |
test_one() | |
{ | |
local dir="a" | |
message 'Test One: `git replace` and git `filter-branch`' | |
rm -rf "${dir}" && mkdir "${dir}" && cd "${dir}" | |
init_repo | |
# Replace "bbb" with "aaa" | |
$GIT replace f761ec192d9f0dca3329044b96ebdb12839dbff6 72943a16fb2c8f38f9dde202b7a70ccc19c52f34 | |
message 'With `master`' | |
$GIT filter-branch -f --prune-empty -- master | |
message 'With `--all`' | |
$GIT filter-branch -f --prune-empty -- --all | |
message 'With `master` and `--tree-filter true`' | |
$GIT filter-branch -f --prune-empty --tree-filter true -- master | |
} | |
# test `git replace` and `git log` | |
test_two() | |
{ | |
local dir="a" | |
message 'Test Two: `git replace` and `git log`' | |
rm -rf "${dir}" && mkdir "${dir}" && cd "${dir}" | |
init_repo | |
# | |
git replace HEAD HEAD~2 | |
git log --all | |
} | |
test_one | |
test_two |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment