From 8638245e5f0b1407510e8daa232a85ffd8911e95 Mon Sep 17 00:00:00 2001 From: Harry Osmar Sitohang Date: Wed, 3 Jun 2020 15:11:20 +0700 Subject: [PATCH 1/4] Update Daniel_Kumala.txt --- Daniel_Kumala.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Daniel_Kumala.txt b/Daniel_Kumala.txt index ef570e3..f459506 100644 --- a/Daniel_Kumala.txt +++ b/Daniel_Kumala.txt @@ -1,3 +1,4 @@ TESTING Hi +1 From 37e6c8bec2934093246252e3242dd69339923227 Mon Sep 17 00:00:00 2001 From: Harry Osmar Sitohang Date: Wed, 3 Jun 2020 22:55:24 +0700 Subject: [PATCH 2/4] Update README.md --- README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3377322..b3930d6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,60 @@ # git-training -![git commit flow](https://github.com/harryosmar/git-training/blob/master/git-commit-flow-v2.png) \ No newline at end of file +![git commit flow](https://github.com/harryosmar/git-training/blob/master/git-commit-flow-v2.png) + +## Branches + + +- Create branch from `master` branch + +``` +// update current master branch +(master) $ git pull origin master + +// create the new branch from updated master +(master) $ git checkout -b feature/my_branch + +// Switched to a new branch 'xyz', then push the new branch to github +(feature/my_branch) $ git push origin feature/my_branch +``` + +- Switch branch + +``` +// switch to branch feature/1 +(master) $ git checkout feature/1 + +// Switched to branch 'feature/1' +(feature/1) $ + +// switch back to branch master +(feature/1) $ git checkout master + +// Switched to branch 'master' +(master) $ +``` + +- merge update between branch + +``` +// update current master branch +(master) $ git pull origin master + +// create the new branch from updated master +(master) $ git checkout -b feature/my_branch + +// in the new branch, create file with name `hello.txt` and content "Hello World", file status `untracked` +(feature/my_branch) $ echo "Hello World" >> hello.txt + +// change file status to `staged` +(feature/my_branch) $ git add hello.txt + +// commit file with `staged` status, this commit mark `hello.tx` file so it's belongs to `feature/my_branch` +(feature/my_branch) $ git commit -m "add hello.txt file" + +// switch back to branch master +(feature/my_branch) $ git checkout master + +// merge FROM `feature/my_branch` TO `master` +(master) $ git merge feature/my_branch +``` From 6efa2717ec1eb34a6f813ed72a146aa5fe720870 Mon Sep 17 00:00:00 2001 From: Harry Osmar Sitohang Date: Wed, 3 Jun 2020 22:58:06 +0700 Subject: [PATCH 3/4] Update README.md --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b3930d6..bbc8186 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,14 @@ // create the new branch from updated master (master) $ git checkout -b feature/my_branch -// Switched to a new branch 'xyz', then push the new branch to github +// Switched to a new branch `feature/my_branch`, then push it to github (feature/my_branch) $ git push origin feature/my_branch + +// create the new branch from `feature/my_branch` +(feature/my_branch) $ git checkout -b feature/my_branch_v2 + +// Switched to a new branch `feature/my_branch_v2`, then push it to github +(feature/my_branch_v2) $ git push origin feature/my_branch_v2 ``` - Switch branch @@ -34,7 +40,7 @@ (master) $ ``` -- merge update between branch +- merge update between branches ``` // update current master branch @@ -55,6 +61,6 @@ // switch back to branch master (feature/my_branch) $ git checkout master -// merge FROM `feature/my_branch` TO `master` +// merge FROM `feature/my_branch` TO `master`, so master will also has `hello.tx` file (master) $ git merge feature/my_branch ``` From aff6865fdbad4b338135b5eb6c274ecab89c065a Mon Sep 17 00:00:00 2001 From: Harry Osmar Sitohang Date: Wed, 3 Jun 2020 23:05:02 +0700 Subject: [PATCH 4/4] Update README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index bbc8186..f55488d 100644 --- a/README.md +++ b/README.md @@ -64,3 +64,22 @@ // merge FROM `feature/my_branch` TO `master`, so master will also has `hello.tx` file (master) $ git merge feature/my_branch ``` + +- Tagging/Release + +``` +// create tag `v1.0.0` from `master` branch +(master) $ git tag -a v1.0.0 -m "First release" + +// switch to tag `v1.0.0` +(master) $ git checkout v1.0.0 + +// push tag `v1.0.0` to github +(master) $ git push origin v1.0.0 + +// create new branch from tag `v1.0.0` +((HEAD detached at v1.0.0)) $ git checkout -b feature/bugfix + +// Switched to a new branch 'feature/bugfix', contains the same commits with tag `v1.0.0` +(feature/bugfix) $ +```