Skip to content

Instantly share code, notes, and snippets.

@chilversc
Created December 7, 2011 10:45
Show Gist options
  • Select an option

  • Save chilversc/1442357 to your computer and use it in GitHub Desktop.

Select an option

Save chilversc/1442357 to your computer and use it in GitHub Desktop.
Problem merging changes to file that was renamed
#!/bin/sh
# Create empty repository for testing
mkdir cherrypick
cd cherrypick
git init
# Simulate some initial work
echo bob > a.txt
git add a.txt
git commit -m "bob"
# Simulate performing a spike to test something out
git checkout -b other
mkdir foo
mv a.txt foo/
echo jim > foo/a.txt
git add -A
git commit -m "jim"
# Simulate doing some other work on the master
# This work includes part of the change made by the spike
# Including the rename of a.txt => foo/a.txt
git checkout master
mkdir foo
mv a.txt foo/
git add -A
git commit -m "move a.txt"
# Try to merge the spike in to incorporate the changes to foo/a.txt
git merge --no-commit --squash other
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment