[email protected] 的使用

git的优势

  1. 大部分操作在本地完成,不需要联网
  2. 完整性保证
  3. 尽可能添加数据而不是删除或修改数据
  4. 分支操作非常快捷流畅
  5. 与linux命令全面兼容

本地库和远程库

[email protected] 的使用

 

[email protected] 的使用

 

本地库操作

1.本地库初始化

命令:git init

[email protected] 的使用

注意:.git目录存放的是本地库相关的子目录和文件,不要删除,也不要胡乱修改

2.设置签名

形式

用户名:

Email:

作用:区分不同开发人员的身份

辨析:和登录远程库的账号和密码没有关系

命令

项目级别/仓库级别:仅在当前本地库范围有效

git config user.name tom

git config user.email [email protected]

系统用户级别:登录当前操作系统的用户范围

git config --global user.name tom

git config --global user.email [email protected]

级别优先级     就近原则:项目级别优先于系统用户级别(二者都没有不允许)

保存的位置  ~/.gitconfig

基本操作

[email protected] 的使用

 

git log 

[email protected] 的使用

[email protected] 的使用

前进后退版本

基于索引值

git reset --hard [索引值]

基于~符号 只能后退

git reset --hard HEAD~n

n表示回退的步数

基于^符号 只能往后退

git reset --hard HEAD^

一个^表示回退一个版本

reset的三个参数对比

[email protected] 的使用

文件比较

[email protected] 的使用

分支管理

[email protected] 的使用

[email protected] 的使用

 [email protected] 的使用