git 笔记

173 阅读1分钟

多个commit合并一个

  • git rebase -i  commitId (这个id之前的)  
  • git push -f

 pick 121ab3f fix:格式化1
 squash 121ab3f fix:格式化2   #pick 修改为squash
 squash 121ab3f fix:格式化3   #pick 修改为squash

 # Rebase 7b94b31..121ab3f onto 7b94b31 (1 command)
 #
 # Commands:
 # p, pick = use commit
 # r, reword = use commit, but edit the commit message
 # e, edit = use commit, but stop for amending
 # s, squash = use commit, but meld into previous commit
 # f, fixup = like "squash", but discard this commit's log message
 # x, exec = run command (the rest of the line) using shell
 # d, drop = remove commit


分支关联

  • 远程已有remote_branch分支但未关联本地分支local_branch且本地已经切换到local_branch
    • git push -u origin/remote_branch
  • 远程没有有remote_branch分支并,本地已经切换到local_branch
    • git push origin local_branch:remote_branch


代码统计

git log --pretty=format:"%ad,%aN,%aE" --shortstat --date-order --date=short --no-merges --author="zhangsan"  --since="2019-01-01" --until="2019-03-31"


提交代码规范

  • feat:新功能(feature)

  • fix:修补bug

  • docs:文档

  • style: 格式(不影响代码运行的变动)

  • refactor:重构(即不是新增功能,也不是修改bug的代码变动)

  • test:增加测试