Skip to content

Instantly share code, notes, and snippets.

@choroba
Created February 28, 2020 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choroba/f2b4dadacc2a86788f97405e43e27ae7 to your computer and use it in GitHub Desktop.
Save choroba/f2b4dadacc2a86788f97405e43e27ae7 to your computer and use it in GitHub Desktop.
Git rebase with copy
#!/bin/bash
set -eu
tmp=$(mktemp -d)
cd "$tmp"
git init
git config user.email abc@example.com
echo file a > a.txt
echo file b > b.txt
git add [ab].txt
git commit -m 'init'
git checkout -b copy
cp a.txt A.txt
cp b.txt B.txt
git add [AB].txt
git commit -m 'copy'
git checkout master
echo fix >> a.txt
git add a.txt
git commit -m 'fix'
git checkout copy
git rebase master
git log --follow --stat A.txt | grep -C4 fix
rm -rf "$tmp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment