提示和参考¶
本章包含有关git修订控制系统的其他资料。如果您坚持使用Sage开发脚本,就没有必要了。看到了吗 设置Git 对于Sage开发所需的最小步骤。
配置提示¶
您的个人Git配置保存在 ~/.gitconfig
在你的主目录中。下面是一个例子:
[user]
name = Your Name
email = you@yourdomain.example.com
[core]
editor = emacs
您可以直接编辑此文件,也可以使用git为您进行更改:
[user@localhost ~] git config --global user.name "Your Name"
[user@localhost ~] git config --global user.email you@yourdomain.example.com
[user@localhost ~] git config --global core.editor vim
别名¶
别名是git命令的个人快捷方式。例如,您可能希望能够缩短 git checkout
到 git co
. 或者你可以化名 git diff --color-words
(它提供了格式良好的diff输出)到 git wdiff
. 你可以这样做:
[user@localhost ~] git config --global alias.ci "commit -a"
[user@localhost ~] git config --global alias.co checkout
[user@localhost ~] git config --global alias.st "status -a"
[user@localhost ~] git config --global alias.stat "status -a"
[user@localhost ~] git config --global alias.br branch
[user@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
合并¶
执行合并时强制执行摘要 (~/.gitconfig
再次提交文件:
[merge]
log = true
或者从命令行:
[user@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
使用这个 lg
alias为您提供了带有彩色ascii图形的changelog::
[user@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]
| |\
| |/
教程和摘要¶
网上有很多教程和命令摘要。
初学者¶
Try Git 是一个入门级教程,您可以在浏览器中进行。如果您不熟悉修订控制,您需要密切关注底部的“建议”部分。
Git magic 是一个带有中间细节的扩展介绍。
这个 git parable 解释Git背后的概念很容易。
Git foundation 扩展到 git parable .
虽然它也包含了关于分支和分离头等更先进的材料,但是在 Learn Git Branching 真的很有帮助。
先进的¶
Github help 拥有一系列优秀的操作指南。
这个 pro git book 是一本关于git的深入的书。
Github Training 有一个优秀的系列教程,以及视频和屏幕截图。
这个 git tutorial .
Git ready 是一系列不错的教程。
Fernando Perez' git page 包含许多链接和提示。
一个很好但技术性很强的页面 git concepts
Git svn crash course: git for those of us used to subversion
摘要/备忘单¶
A git cheat sheet 是一个提供常用命令摘要的页面。
这个 git user manual .
Git最佳实践¶
与Git合作的方式有很多种;下面是一些关于经验法则的帖子,其他项目都提出了:
Linus Torvalds开 git management
Linus Torvalds开 linux git workflow . 摘要:使用git工具使编辑的历史尽可能干净;在您正在进行活动开发的分支中,尽可能少地合并来自上游的编辑。
联机手册页¶
你可以在你自己的机器上用(例如) git help push
或(同一事物) git push --help
但为了方便起见,以下是一些常用命令的联机手册页: