0%

git百宝箱

git 代理设置

1
2
3
4
git config --global http.proxy 'http://127.0.0.1:1087'
git config --global https.proxy 'http://127.0.0.1:1087'
git config --global http.proxy 'socks5://127.0.0.1:1086'
git config --global https.proxy 'socks5://127.0.0.1:1086'

git取消代理

1
2
git config --global --unset http.proxy
git config --global --unset https.proxy

git查看代理

方法一
1
cat ~/.gitconfig
方法二
1
git config --global http.proxy

删除git已缓存的文件夹:

1
2
git rm --cached "文件路径"
git rm -r --cached .vscode/

设置git的默认编辑器为vim:

1
git config --global core.editor vim

注释填写错误重填命令:

1
git commi --amend

merge合并到主分支的正确方式

1
git merge --no-ff feat-homepage

删除本地分支

1
git branch -d

git提交规范

https://www.yuque.com/fe9/basic

type 是用于说明该 commit 的类型的,一般我们会规定 type 的类型如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
feat: 新功能(feature)<br>
fix: 修复 bug<br>
docs: 文档(documents)<br>
style: 代码格式(不影响代码运行的格式变动,注意不是指 CSS 的修改)<br>
refactor: 重构(既不是新增功能,也不是修改 bug 的代码变动)<br>
test: 提交测试代码(单元测试,集成测试等)<br>
chore: 构建或辅助工具的变动<br>
misc: 一些未归类或不知道将它归类到什么方面的提交<br>
scope。scope 说明 commit 影响的范围,比如数据层,控制层,视图层等等,这个需要视具体场景与项目的不同而灵活变动<br>
subject。subject 是对于该 commit 目的的简短描述<br>
使用第一人称现在时的动词开头,比如 modify 而不是 modified 或 modifies<br>
首字母小写,并且结尾不加句号<br>
ISSUEE_ID。这个与公司的需求管理与项目管理有关,假设你的项目放在 github 上,你的需求或者 bug 修复可能会有对应的 issues 记录,你可以加到你的 commit 信息中如 issue-37938634。<br>

强制将两个不相干的仓库合并

1
git pull origin master --allow-unrelated-histories

分支开发策略

分支管理-廖雪峰

强制覆盖远程分支

1
git push origin 分支名 —force

测试ssh_key是否有效

1
ssh -T git@github.com

git未知

1
git的unshallow和--depth=1

提交指定文件夹下的所有文件到指定分支

git subtree push —prefix=dist origin gh-pages
git subtree push —prefix=dist git@github.com:htongxxx/xxxx.git gh-pages
git push using: git@github.com:htongxxxxx/xxxx.git gh-pages