前言
随着 git 的应用普遍化,当初更须要关注应用的标准流程,在此纪录。
目录
- 丑陋的徽章
- 更好的 pull
- 配置代理及勾销代理
- rebase 命令批改 commit 提交历史
- Git-merge 时疏忽文件
丑陋的徽章
继续集成
npm
自定义
能够自定义批改 左侧 label 文字,右侧色彩
其余
更好的 pull
起因
git pull origin xxx --rebase# 间接按 rebase 的形式执行 pullgit config --global pull.rebase true
应用 rebase 就感觉所有人都在同一条直线上开发一样,很洁净的 log,看着很难受,而间接应用 pull 的 log 看起来就很乱。
git pull --rebase
* | b9feea8 - chore: 增加C返回A埋点 (6 hours ago) <yanyue404>* | b3047fe - fix: ISO8601 time (6 hours ago) <yanyue404>* | bfb6c84 - test: formatTimeStr 兼容 ios (7 hours ago) <yanyue404>* | 0e13196 - chore: IOS 工夫解决 (22 hours ago) <yanyue404>* | f15a0e8 - chore: 游客在名片页面进行受权 (24 hours ago) <yanyue404>* | ee8b125 - chore: 欠缺集体名片 (25 hours ago) <yanyue404>* | deb7a5a - chore: 集体名片增加用户角色校验 (26 hours ago) <yanyue404>* | 5106b02 - chore: 开始辨认用户角色 (27 hours ago) <yanyue404>* | f16b6af - chore: 更换 appid (31 hours ago) <yanyue404>* | 7216da4 - chore: 同步 code (31 hours ago) <yanyue404>* | 9e542b4 - chore: uat 更新 (6 days ago) <yanyue404>* | 473e311 - fix: 批改环境 (6 days ago) <yanyue404>* | f54ae0f - chore: 埋点 (5 hours ago) <yanyue404>
git pull
* | ae57454 - feat: token 过期强制从新认证 (2 days ago) <yanyue404>* | 1b02194 - Merge remote-tracking branch 'origin/prod' into prod (2 days ago) <Joe>|\ \| * | 6284b85 - fix: 登录流程短视频播放 (2 days ago) <yanyue404>| * | 2bcb162 - styles: canvas 分享图地位优化 (2 days ago) <yanyue404>| * | d4c66a6 - chore: 页面分享管制 (2 days ago) <yanyue404>| * | 91baa28 - chore: 集体名片非分享人文字批改 (2 days ago) <yanyue404>* | | 60715e9 - 批改保单判断 (2 days ago) <Joe>|/ /* | 85f1032 - Merge remote-tracking branch 'origin/prod' into prod (2 days ago) <Joe>|\ \| * | ab884df - feat: 集体名片分享页受权 (4 days ago) <yanyue404>* | | e603434 - 优化加载速度 (2 days ago) <Joe>|/ /* | a255e59 - 微调款式 评论换行 (4 days ago) <Joe>* | 7251630 - Merge remote-tracking branch 'origin/prod' into prod (4 days ago) <Joe>|\ \| * | 1bd08fc - chore: loading 优化 (4 days ago) <yanyue404>* | | 7bc0e9e - 批改视频列表问题 (4 days ago) <Joe>|/ /* | 9e328af - 1.勾销我的视频 集体名片换上来 (4 days ago) <Joe>
配置代理及勾销代理
Error: Filed to connecto to github.com port 443: Time out
# 设置git config --global http.proxy http://127.0.0.1:51349# 勾销git config --global --unset http.proxy
rebase 命令批改 commit 提交历史
合并最近提交的历史,将 ba4358d
到 a549037
变为一个 commit
# 输出git log --online# 输入ba4358d (HEAD -> master, origin/master, origin/HEAD) docs: 重ba4358d Update README.mdba4358d Update README.md # 此条目以上合并为一条36f95d9 docs0312afb init
筹备合并
git rebase -i 36f95d9 | git rebase -i HEAD~3
抉择合并
# 输入pick ba4358d '正文**********'pick ba4358d '正文*********'pick ba4358d '正文**********'# pick 的意思是要会执行这个 commit# squash 的意思是这个 commit 会被合并到前一个commit (省略写法 s)# 在 vim 命令下输出 i 进入编辑模式,编辑实现后 :eq 保留退出# 输出pick 3ca6ec3 '正文**********'s 1b40566 '正文*********'s 53f244a '正文**********'
保留实现后,你有两个抉择
git rebase --continue # 确认 rebasegit rebase --abort # 勾销 rebase#确认后,就能够上传到近程了。
如果没有抵触,或者抵触曾经解决,则会呈现如下的编辑窗口, 输出:wq
保留并推出:
# This is a combination of 4 commits.#The first commit’s message is:正文......# The 2nd commit’s message is:正文......# The 3rd commit’s message is:正文......# Please enter the commit message for your changes. Lines starting # with ‘#’ will be ignored, and an empty message aborts the commit.
查看历史,曾经扭转
git log --onelined2d71a5 (HEAD -> master) Update README.md36f95d9 docs0312afb init
git push -f # 强制笼罩近程git commit --amend -m "新的正文" # 批改最新的 git commit 正文
Git-merge 时疏忽文件
揭示: 只能 master 合并其余分支时疏忽其余分支上的文件, 其余分支合并 master 无奈疏忽 master 上的文件. (master 为默认主分支)
- 创立自定义 merge driver
git config --global merge.ours.driver true
- 在要被 merge 的分支上创立.gitattributes 文件,并且在文件中置顶不 merge 的文件名
project.config.json merge=oursfetch.js merge=oursapp.js merge=ours
- 回到要合并到的分支 master,执行 merge:
git merge uat
在 uat
分支上的project.config.json
、fetch.js
、app.js
就不会被合并了 !
参考链接
- Git 应用标准流程, by 阮一峰
- Git 近程操作详解, by 阮一峰
- Understanding the GitHub flow
- Learn Git Branching / 网友答复
- https://stackoverflow.com/que...
- GitHub 我的项目徽章的增加和设置
- https://shields.io/