Created
January 15, 2017 02:26
-
-
Save hugolu/5f2b7e442e9350bb85d42bb381ec929b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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