1.配置github
- 进入页面
- 点击
New SSH key
,输入Title
,然后按照以下步骤生成key,并将key复制到网页中 ssh-keygen -t rsa -b 4096 -C "你的邮箱"
- 回车三次
cat ~/.ssh/id_rsa.pu
,完整复制这些key,到网页中对应Title对应的key位置- 回到git bash,运行
ssh -T git@github.com
,看到以下提示表示成功
2.配置git
git config --global user.name 你的英文名 #此英文名不需要跟GitHub账号保持一致
git config --global user.email 你的邮箱 #此邮箱不需要跟GitHub账号保持一致
git config --global push.default matchinggit config --global core.quotepath false
git config --global core.editor "vim"
git config --list #查看当前git的配置情况
3.获取git帮助手册
git help config
git commit -h # 获得add相关的帮助
平时在使用的过程中,如果忘记某个指令的参数,比如git commit
,可以通过git commit -h
添加-h
来查看手册,里面会有详细的参数说明,就像Linux中的man手册一样,非常方便。
$ git commit -h
usage: git commit [<options>] [--] <pathspec>...
-q, --quiet suppress summary after successful commit
-v, --verbose show diff in commit message template
Commit message options
-F, --file <file> read message from file
--author <author> override author for commit
--date <date> override date for commit
-m, --message <message>
commit message
-c, --reedit-message <commit>
reuse and edit message from specified commit
-C, --reuse-message <commit>
reuse message from specified commit
--fixup [(amend|reword):]commit
use autosquash formatted message to fixup or amend/reword specified commit
--squash <commit> use autosquash formatted message to squash specified commit
--reset-author the commit is authored by me now (used with -C/-c/--amend)
--trailer <trailer> add custom trailer(s)
-s, --signoff add a Signed-off-by trailer
-t, --template <file>
use specified template file
-e, --edit force edit of commit
--cleanup <mode> how to strip spaces and #comments from message
--status include status in commit message template
-S, --gpg-sign[=<key-id>]
GPG sign commit
Commit contents options
-a, --all commit all changed files
-i, --include add specified files to index for commit
--interactive interactively add files
-p, --patch interactively add changes
-o, --only commit only specified files
-n, --no-verify bypass pre-commit and commit-msg hooks
--dry-run show what would be committed
--short show status concisely
--branch show branch information
--ahead-behind compute full ahead/behind values
--porcelain machine-readable output
--long show status in long format (default)
-z, --null terminate entries with NUL
--amend amend previous commit
--no-post-rewrite bypass post-rewrite hook
-u, --untracked-files[=<mode>]
show untracked files, optional modes: all, normal, no. (Default: all)
--pathspec-from-file <file>
read pathspec from file
--pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character
4.参考资料
windows版的Git镜像:下载地址
参考官方文档:很详尽的官方文档,需要了解哪一部分,可以选择性地查阅。其中有Git内部原理。
图解Git:稍微理解了Git的基本工作原理,这篇文章通过图形化让你理解的更加透彻。
Learning Git Branching:非常棒的动画教程,像玩游戏一样练习Git。