git最佳实践

2020/10/16 git

使用git过程中的一些最佳实践

用git缩写命令

把下面配置添加到用户根目录下面的.gitconfig配置文件中

[alias]
  st = status
  ci = commit
  br = branch
  co = checkout

在主分支上合并commit (待验证)

  • 主分支是develop,本地分支是feature
// 把feature分支合并到develop分支,同时合并feature上的多个提交
// 先check out到develop分支,再执行下面命令,最后显式commit
// --squash选项不会自动commit
git merge --squash feature

在本地分支上合并主分支commit

  • 主分支是develop,本地分支是feature
// git pull origin master 会多出一个merge commit
// --rebase 会先将主分支commit应用到本地分支,再把本地分支的commit加在后面,不会多出一个
// merge commit,除非有冲突需要显式merge
git pull --rebase origin master

Search

    Table of Contents