Skip to content

Instantly share code, notes, and snippets.

@hugolu
Created January 15, 2017 02:26
Show Gist options
  • Save hugolu/5f2b7e442e9350bb85d42bb381ec929b to your computer and use it in GitHub Desktop.
Save hugolu/5f2b7e442e9350bb85d42bb381ec929b to your computer and use it in GitHub Desktop.
# init repository
rm -rf learn-git
mkdir learn-git
cd learn-git
git init
# commit changes
echo 1 >> file
git add .
git commit -m "1"
echo 2 >> file
git commit -am "2"
# create branch
git checkout -b dev
echo 3 >> file
git add .
# stash changes
git stash
# switch branch to master
git checkout master
# create branch
git checkout -b hotfix
# fix bug
sed -i '' -e 's/2/two/g' file
git commit -am "hotfix"
# switch branch to master
git checkout master
# merge hotfix
git merge --no-ff hotfix
git branch
git log --oneline
cat file
# switch branch to dev
git checkout dev
git branch
git log --oneline
cat file
# restore changes
git stash list
git stash pop
git branch
git log --oneline
cat file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment