GIT/GIT FLOW

Contents

  • GIT BASE
  • GIT TIPS
  • GIT FLOW

1.GIT BASE

(origin)

(local)

origin/master
origin/develop
origin/feature/one
origin/feature/two
origin/feature/others
...
master
develop
feature/one
feature/two
feature/my-own
hotfix/my-own
...

git fetch

git add path/to/files
git commit
git checkout path/to/files
git reset HEAD path/to/files
git reset
git push origin xxx

HEAD

2.GIT TIPS

Orders You Need To Know

  • git branch [-a|-D branch-name]
  • git checkout -b new-branch
  • git checkout branch-name
  • git push/pull origin branch-name
  • git stash [list|pop]
  • git status/diff
  • git log
  • git merge --no-ff branch-name
  • ...

Git Merge

why git merge --no-ff ?

Merge Conflicts

<<<<<<< HEAD:xxxx
//Your Code Here
...
================
//Origin Code
...
>>>>>>> conflictBranch:xxxx
//step1
与冲突代码的提交人核对冲突代码的取舍或者合并
//step2
处理完所有的冲突后
git add path/to/files
//step3
git commit
(Attation: 没有-m,直接git commit即可)

Avoid Conflicts

良好的代码更新和推送习惯

良好的分支管理

  • 养成习惯开发前先git pull更新本地代码仓库
  • 分支职能需严格遵守
  • 功能分支合并到develop前,合并develop到功能分支,在功能分支中修改冲突
  • ...

Ex:

Use Alias

//config
git config --gloabl alias.st "status"

//Output
git st === git status

<b>Less Input,Higher Efficient</b>

<del>装B利器</del>

3.GIT FLOW

What‘s Git Flow?

  • Git标准化开发模型/最佳实践
  • Git使用规范
  • ...
  • master
  • develop
  • feature/xx
  • release/xx
  • hotfix/xx

Attention

  • 分支应保持功能独立,不可越俎代庖
  • feature、hotfix...Expire-Time...Just Del it
  • 需要多人协作的push到origin,独立开发 no...

End With Materials

Made with Slides.com