0 README
本文总结了郭霖在《第一行代码:android》一书中提到的版本管理工具Git的使用方法,以及廖雪峰的Git教程,并加入自己的理解。本文讲述了如何管理本地文件版本仓库,以及如何下载、同步和修改GitHub上的仓库。
文章目录
1 准备工作
1)安装
https://gitforwindows.org/
2)进入git bash
命令行
3)配置用户信息
git config --global user.name "Xiang Gao"
git config --global user.email "xiangaoo@163.com"
配置 Git 时,--global
参数针对当前用户起作用(保存在用户文档目录的 .gitconfig
文件中),如果不加那只对当前所在仓库起作用(保存在当前仓库的 .git/config
文件中)。
执行上述配置命令后,.gitconfig
内容变为:
[user]
name = Xiang Gao
email = xiangaoo@163.com
同样的方式可以给 Git 命令配置别名,比如查看提交记录使用自定义的 lg
别名:
git config --global alias.lg "log --color --graph --pretty=format:\
'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' \
--abbrev-commit"
4)测试用户信息是否添加成功
git config --global user.name
# output:
# "Xiang Gao"
2 仓库操作 repository
仓库(repository
)是文件版本管理的基本单元,存放版本管理所需的信息。所有本地提交(c