Git提示和参考资料¶
本章包含有关Git版本控制系统的其他材料。看见 设置Git 用于开发Sage所需的最小步骤。
配置提示¶
您的个人Git配置保存在 ~/.gitconfig
您的主目录中的文件。下面是一个例子:
[user]
name = Alice Adventure
email = alice@wonderland.com
[core]
editor = emacs
您可以直接编辑此文件,也可以使用Git为您进行更改:
[alice@localhost ~]$ git config --global user.name "Alice Adventure"
[alice@localhost ~]$ git config --global user.email alice@wonderland.com
[alice@localhost ~]$ git config --global core.editor vim
别名¶
别名是Git命令的个人快捷方式。例如,您可能希望能够缩短 git checkout
至 git co
。或者,您可能希望使用别名 git diff --color-words
(它给出了一个格式良好的diff输出) git wdiff
。您可以使用以下命令执行此操作:
[alice@localhost ~]$ git config --global alias.ci "commit -a"
[alice@localhost ~]$ git config --global alias.co checkout
[alice@localhost ~]$ git config --global alias.st "status -a"
[alice@localhost ~]$ git config --global alias.stat "status -a"
[alice@localhost ~]$ git config --global alias.br branch
[alice@localhost ~]$ git config --global alias.wdiff "diff --color-words"
上面的命令将创建一个 alias
部分在您的 .gitconfig
包含如下内容的文件:
[alias]
ci = commit -a
co = checkout
st = status -a
stat = status -a
br = branch
wdiff = diff --color-words
编者¶
要设置用于编辑提交消息的编辑器,您可以使用::
[alice@localhost ~]$ git config --global core.editor vim
或将 EDITOR
环境变量。
正在合并¶
在执行合并时强制执行汇总 (~/.gitconfig
再次提交):
[merge]
log = true
或从命令行::
[alice@localhost ~]$ git config --global merge.log true
花式原木输出¶
下面是一个别名,用来获得漂亮的日志输出。它应该放在 alias
您的部分 .gitconfig
文件:
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)[%an]%Creset' --abbrev-commit --date=relative
Using this lg
alias gives you the changelog with a colored ASCII graph:
[alice@localhost ~]$ git lg
* 6d8e1ee - (HEAD, origin/my-fancy-feature, my-fancy-feature) NF - a fancy file (45 minutes ago) [Matthew Brett]
* d304a73 - (origin/placeholder, placeholder) Merge pull request #48 from hhuuggoo/master (2 weeks ago) [Jonathan Terhorst]
|\
| * 4aff2a8 - fixed bug 35, and added a test in test_bugfixes (2 weeks ago) [Hugo]
|/
* a7ff2e5 - Added notes on discussion/proposal made during Data Array Summit. (2 weeks ago) [Corran Webster]
* 68f6752 - Initial implementation of AxisIndexer - uses 'index_by' which needs to be changed to a call on an Axes object - this is all very sketchy right now. (2 weeks ago) [Corr
* 376adbd - Merge pull request #46 from terhorst/master (2 weeks ago) [Jonathan Terhorst]
|\
| * b605216 - updated joshu example to current api (3 weeks ago) [Jonathan Terhorst]
| * 2e991e8 - add testing for outer ufunc (3 weeks ago) [Jonathan Terhorst]
| * 7beda5a - prevent axis from throwing an exception if testing equality with non-axis object (3 weeks ago) [Jonathan Terhorst]
| * 65af65e - convert unit testing code to assertions (3 weeks ago) [Jonathan Terhorst]
| * 956fbab - Merge remote-tracking branch 'upstream/master' (3 weeks ago) [Jonathan Terhorst]
| |\
| |/
教程和摘要¶
网上有很多教程和命令摘要。
初学者¶
gittutorial 是Git项目的入门教程。
Git magic 是一个带有中间细节的扩展介绍。
这个 Git parable 是一本解释Git背后的概念的简单读物。
虽然它还包含有关分支和分离的头部等更高级的材料,但在 Learn Git Branching 真的很有帮助。
进阶¶
GitHub help 有一系列出色的操作指南。
这个 pro Git book 是一本深入探讨Git的好书。
Github Training Kit 有一系列优秀的教程、视频和截屏视频。
Git ready 是一系列不错的教程。
一个很好的但技术上的页面 Git concepts
Git最佳实践¶
使用Git的方法有很多种。以下是其他项目提出的一些经验法则的帖子:
莱纳斯·托瓦尔兹上场 Git management 。
莱纳斯·托瓦尔兹上场 Git workflow 。摘要:使用Git工具使您的编辑历史尽可能清晰;在您正在进行活动开发的分支中尽可能少地从上游编辑合并。
在线手册页¶
您可以使用(例如)在您自己的计算机上获取这些内容 git help push
或者(同样的事情) git push --help
,但为方便起见,以下是一些常见命令的在线手册页: