git常见问题

1. Git 基本流程

2. git commit 规范:

常用的 Git commit 规范,没有强制的规定,主要是翻阅以前的日志会更清晰。

基本格式:

git commit -m "type: description"

一个比较详细的格式:

<type>: (If applied, this commit will...) <subject> (Max 50 char)
|<----  Using a Maximum Of 50 Characters  ---->|

Explain why this change is being made
|<----   Try To Limit Each Line to a Maximum Of 72 Characters   ---->|

Provide links or keys to any relevant tickets, articles or other resources
Example: Github issue #23

type 是 commit 的类别,只允许如下几种标识:

  • fix: 修复bug
  • feat/add: 新功能 (new feature)
  • update: 更新
  • refactor : 某个已有功能重构
  • perf : 性能优化
  • style : 代码格式改变 (formatting, missing semi colons, etc; no code change)
  • test: 增加测试代码 (adding or refactoring tests; no production code change)
  • docs : 文档改变 (changes to documentation)
  • revert: 撤销上一次的commit
  • build: 构建工具或构建过程等的变动,如:关联包升级等
  • chore (updating grunt tasks etc; no production code change)

description 是对本次提交的简短描述:

  • 不超过50个字符。
  • 推荐以动词开头,如: 设置、修改、增加、删减、撤销等

参考: https://gist.github.com/adeekshith/cd4c95a064977cdc6c50

3. git 提交空文件夹

在空文件夹下建立 .gitkeep

touch .gitkeep

内容如下:

# Ignore everything in this directory 
* 
# Except this file !.gitkeep 

4. 删除 mac 下面自动生成的 .DS_store

删除所有隐藏.DS_store文件,打开命令行窗口

sudo find . -name ".DS_Store" -depth -exec rm {} \;

设置不再产生选项, 执行如下命令

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

5. 通过修改 hosts 提高 github 访问速度

先去 IPAddress.com 或者 http://tool.chinaz.com/dns 网站,查询3个与GitHub相关网址对应的IP地址:

​ 1、github.com

​ 2、assets-cdn.github.com

​ 3、github.global.ssl.fastly.net

页面上会查看到这3个地址对应的 IP 地址,把查询到的IP和地址加到 hosts 文件下, 比如:

13.250.177.223   github.com

我的系统下hosts文件不能直接保存,那就 copy 到其它路径下,修改保存后再 ctrl+x,ctrl+v 回去;

再清一下系统DNS缓存,

win: cmd命令打开DOS窗口,输入

ipconfig/flushdns

ubuntu 下:

安装并重新启动 nscd 守护程序。

sudo aptitude install nscd
sudo /etc/init.d/nscd restart

6. 如何设置不被追踪的文件

​ 有些文件是不想被追踪的, 可以修改 .git/info/exclude 文件, 以 # 开头,添加规则即可。

这里提供一个比较常见的 .gitignore 文件, 将其命名为 .gitignore 然后放到根目录即可。

7. server certificate verification failed. CAfile:/etc/ssl/certs/ca-certificates.crt CRLfile: none

export GIT_SSL_NO_VERIFY=1

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!