项目作者: harryosmar

项目描述 :
Git training simulation
高级语言:
项目地址: git://github.com/harryosmar/git-training.git
创建时间: 2020-06-02T06:14:26Z
项目社区:https://github.com/harryosmar/git-training

开源协议:

下载


git-training

git commit flow

Branches

Create branch

create branch

  1. // update current master branch
  2. (master) $ git pull origin master
  3. // create the new branch from updated master
  4. (master) $ git checkout -b feature/my_branch
  5. // Switched to a new branch `feature/my_branch`, then push it to github
  6. (feature/my_branch) $ git push origin feature/my_branch
  7. // create the new branch from `feature/my_branch`
  8. (feature/my_branch) $ git checkout -b feature/my_branch_v2
  9. // Switched to a new branch `feature/my_branch_v2`, then push it to github
  10. (feature/my_branch_v2) $ git push origin feature/my_branch_v2

Switch branch

switch branch

  1. // switch to branch feature/1
  2. (master) $ git checkout feature/1
  3. // Switched to branch 'feature/1'
  4. (feature/1) $
  5. // switch back to branch master
  6. (feature/1) $ git checkout master
  7. // Switched to branch 'master'
  8. (master) $

Merge update between branches

merge branch

  1. // update current master branch
  2. (master) $ git pull origin master
  3. // create the new branch from updated master
  4. (master) $ git checkout -b feature/my_branch
  5. // in the new branch, create file with name `hello.txt` and content "Hello World", file status `untracked`
  6. (feature/my_branch) $ echo "Hello World" >> hello.txt
  7. // change file status to `staged`
  8. (feature/my_branch) $ git add hello.txt
  9. // commit file with `staged` status, this commit mark `hello.tx` file so it's belongs to `feature/my_branch`
  10. (feature/my_branch) $ git commit -m "add hello.txt file"
  11. // switch back to branch master
  12. (feature/my_branch) $ git checkout master
  13. // merge FROM `feature/my_branch` TO `master`, so master will also has `hello.tx` file
  14. (master) $ git merge feature/my_branch

Tagging/Release

tagging

  1. // create tag `v1.0.0` from `master` branch
  2. (master) $ git tag -a v1.0.0 -m "First release"
  3. // switch to tag `v1.0.0`
  4. (master) $ git checkout v1.0.0
  5. // push tag `v1.0.0` to github
  6. (master) $ git push origin v1.0.0
  7. // create new branch from tag `v1.0.0`
  8. ((HEAD detached at v1.0.0)) $ git checkout -b feature/bugfix
  9. // Switched to a new branch 'feature/bugfix', contains the same commits with tag `v1.0.0`
  10. (feature/bugfix) $