Skip to content

Instantly share code, notes, and snippets.

@soltys
Last active January 9, 2018 16:42
Show Gist options
  • Save soltys/687ec46ee6995beed4bc89a0bcb6c34b to your computer and use it in GitHub Desktop.
Save soltys/687ec46ee6995beed4bc89a0bcb6c34b to your computer and use it in GitHub Desktop.
git_how_to_mess_up_merge
@echo off
rem script for Windows
git init
echo George Washington >> us_presidents.txt
echo John Adams >> us_presidents.txt
echo Thomas Jefferson >> us_presidents.txt
git add .
git commit -am "first us presidents"
echo James Madison >> us_presidents.txt
echo James Monroe >> us_presidents.txt
echo John Quincy Adams >> us_presidents.txt
git commit -am "Democratic-Republican presidents"
git checkout -b feature/Democratic
echo Andrew Jackson >> us_presidents.txt
echo Martin Van Buren >> us_presidents.txt
git commit -am "Presidents up to 1841"
git checkout master
echo William Henry Harrison >> short_lived_us_presidents.txt
git add .
git commit -am "Died in office after 31 days :("
git checkout feature/Democratic
git merge master --no-commit
git stash save
git stash pop
git commit -am "merge from master"
rem f there were uncommitted worktree changes present when the merge started, git merge --abort will in some cases be unable to reconstruct these changes. It is therefore recommended to always commit or stash your changes before running git merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment