配置
- 显示所有配置
git config --list
git config -l
- 添加全局配置
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
- 为本地的工程添加单独的配置,使用不同的用户名和密码
git config
git config
常见操作
- base
git add
git commit -m ''
- 给文件重命名的基本方法
git mv [file] [newfile]
- 查看版本演变
git log
git log --oneline
git log --pretty=oneline
git log -n4 --oneline
git log --graph
git branch -v
git checkout -b temp(分支名) 412da1q1r(某一次提交的commitID)
git log --all
git log --all --graph
- .git目录
- HEAD:记录当前工作区的分支名,指向当前的工作路径
- config:存放当前仓库使用的配置文件,存储当前用户名和邮箱还有一些其他的
git cat-file 命令 显示版本库对象的内容、类型及大小信息。
git cat-file -t 显示版本库对象的类型
git cat-file -s 显示版本库对象的大小
git cat-file -p 显示版本库对象的内容
- refs/heads:存放分支
- refs/tags:存放tags
- objects:存放对象
- HEAD和branch
- 指代新分支的最后一次提交
- 不跟分支挂钩,指向某个commit
- 分支切换时,HEAD指向新分支
git checkout -b <newName> <branchName>
git diff <commit1> <commit2>
git diff HEAD HEAD^1
git diff HEAD HEAD~1
git diff HEAD HEAD~2