Skip to content

Instantly share code, notes, and snippets.

@dkirrane
Created November 21, 2013 13:51
Show Gist options
  • Save dkirrane/7581863 to your computer and use it in GitHub Desktop.
Save dkirrane/7581863 to your computer and use it in GitHub Desktop.
Gist to create a Git reppo and rename and modify a file on 2 different branches
#!/bin/sh
##
# Gist to create a Git reppo and rename and modify a file on 2 different branches
##
mkdir renameTest
cd renameTest
git init
# Init project
echo "base" > data.txt
git add -A
git commit -m "Initial project"
# Branch and rename file
git checkout -b myBranch
mv data.txt data-renamed.txt
git add -A
git commit -a -m "renamed"
# Make a change to renamed file
echo "remote" >> data-renamed.txt
git add -A
git commit -a -m "myBranch commit"
# Checkout master and make a change to original file
git checkout master
echo "local" >> data.txt
git commit -a -m "local"
# Merge
git merge myBranch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment