安装
二进制安装
下载二进制安装文件,直接安装
brew方式
如果你会用brew,那么可以执行:brew install git
,完成安装。
Xcode Command Line Tools
Command Line Tools是在Xcode中的一款工具,可以在命令行中运行C/C++程序,还包含一些命令,就包含Git命令:
xcode-select --install
查看版本#
git --version
常用Git可视化工具简介
- TortoiseGit(小乌龟)
- SourceTree
- Gitfork
常用命令
配置用户信息
git config --global user.name "test"
git config --global user.email "test@163.com"
创建仓库
git init
查看仓库状态
git status
将文件添加到暂存区
git add index.html
或添加所有
git add -A
提交更新
git commit -m "add index file"
查看提交历史
git log
恢复提交历史
git reset --hard HEAD~
恢复到指定提交
git reset --hard 提交id
恢复没有提交到暂存区文件
git restore 文件名称