加载中...

定制Git


git config

更改你的编辑器

  1. $ git config --global core.editor emacs

添加别名

  1. $ git config --global alias.last 'cat-file commit HEAD'
  2. $ git last
  3. tree c85fbd1996b8e7e5eda1288b56042c0cdb91836b
  4. parent cdc9a0a28173b6ba4aca00eb34f5aabb39980735
  5. author Scott Chacon <schacon@gmail.com> 1220473867 -0700
  6. committer Scott Chacon <schacon@gmail.com> 1220473867 -0700
  7. fixed a weird formatting problem
  8. $ git cat-file commit HEAD
  9. tree c85fbd1996b8e7e5eda1288b56042c0cdb91836b
  10. parent cdc9a0a28173b6ba4aca00eb34f5aabb39980735
  11. author Scott Chacon <schacon@gmail.com> 1220473867 -0700
  12. committer Scott Chacon <schacon@gmail.com> 1220473867 -0700
  13. fixed a weird formatting problem

添加颜色

所有的color.*选项请参见git config的文档

  1. $ git config color.branch auto
  2. $ git config color.diff auto
  3. $ git config color.interactive auto
  4. $ git config color.status auto

或者你可以通过color.ui选项把颜色全部打开:

  1. $ git config color.ui true

提交模板

  1. $ git config commit.template '/etc/git-commit-template'

日志格式

  1. $ git config format.pretty oneline

其他配置选项

除上面提到的选项外, 还有很多很有趣的选项去配置打包, 垃圾回收, 合并, 分支, http传输, diff, 分页, 空白字符等等的行为. 如果你需要更加深入地调教git, 请阅读git config文档。


还没有评论.