Git 起步

安装 Git

在 windows 上面安装

简单的方法是安装 GitHub for Windows。 该安装程序包含图形化和命令行版本的 Git。 它也能支持 Powershell,提供了稳定的凭证缓存和健全的 CRLF 设置。

使用 Git 来获取 Git 的升级
$ git clone git://git.kernel.org/pub/scm/git/git.git

初次运行 Git 前的配置

用户信息

安装完成 Git 应该做的第一件事情就是设置用户名称邮件地址。因为每一个 Git 的提交都会使用这些信息,并且它会写入到你的每一次提交中,不可更改:

$ git config --global user.name "xyz"
$ git config --global user.email "[email protected]"

使用了 --global 选项,那么该命令只需要运行一次,因为以后无论你在该系统上做任何事情,Git 都会使用那些信息。当你想针对特定项目使用不同的用户名称与邮件地址时,可以在那个项目目录下运行没有 --global 选项的命令。

文本编辑器

设置默认的文本编辑器,当 Git 需要你输入信息时会调用它。如果 Git 未配置, Git 使用操作系统默认的文本编辑器, 通常是 Vim。 修改不同的文本编辑器命令如下:
$ git config --global core.editor.emacs

检查配置信息

使用 git config --list 命令来列出所有 Git 当时能找打的配置。

$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
user.name=xyz
[email protected]
uesr.name=xyz
[email protected]
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly

能看到重复的变量名,因为 Git 会从不同的文件中读取同一个配置(例如 /etc/gitconfig~/.gitconfig)。 在这种情况下,Git 会使用它找到的每一个变量的最后一个配置。
通过输入 git config :来检查 Git 的某一项配置

$ git config user.name
xyz

获取帮助

Git 命令使用手册获取方法:

$ git help 
$ git  --help
$ man git- 

例如,想要获得 config 命令的手册,执行

$ git help config

你可能感兴趣的:(Git 起步)