diff --git a/notes/.2.2-git_stage.md.swp b/notes/.2.2-git_stage.md.swp new file mode 100644 index 0000000..747f5f5 Binary files /dev/null and b/notes/.2.2-git_stage.md.swp differ diff --git a/notes/2.2-git_stage.md b/notes/2.2-git_stage.md new file mode 100644 index 0000000..e69de29 diff --git a/notes/notes.md b/notes/notes.md new file mode 100644 index 0000000..71f6d5c --- /dev/null +++ b/notes/notes.md @@ -0,0 +1,104 @@ +# git 权威指南 + +## 2.1 Git 初始化 + +### 2.1.1 创建版本库以及第一次提交 + +```git +git config --global user.name "Hanzhang Ma" +git config --global user.email "cxyoz@outlook.com" +``` + +创建别名 + +```bash +$ sudo git config --system alias.br branch +$ sudo git config --system alias.ci "commit -s" +$ sudo git config --system alias.co checkout +$ sudo git config --system alias.st "-p status" +``` + +初始化, 在当前文件夹下新建一个demo的仓库 +```bash +git init demo +``` + +展示所有文件夹里的内容 +```bash +ls -aF +``` + +git会依次向上递归查找.git文件夹来找到根版本库 + +```bash +strace -e 'trace=file' git status +``` + +```bash +git rev-parse --git-dir # .git目录所在位置 +git rev-parse --show-toplevel #工作区根目录 +git rev-parse --show-cdup # 到工作区根目录的方式 +``` + +### 2.1.3 git config参数的区别 + +Git的三个配置文件分别是 + +- 版本库级别的配置文件、 +- 全局配置文件(用户主目录下)和 +- 系统级配置文件(/etc目录下)。 + +其中版本库级别配置文件的优先级最高,全局配置文件其次,系统级配置文件优先级最低。这样的优先级设置就可以让版本库.git目录下的config文件中的配置可以覆盖用户主目录下的Git环境配置。而用户主目录下的配置也可以覆盖系统的Git配置文件。 + +编辑每种配置文件的方式 + +```bash +cd /path/to/myworkspace/ +git config -e +``` + +```bash +git config -e --global#全局 +git config -e --system#系统,可能需要sudo权限 +``` + +git config文件类似这样 +```text +[a] + b = something + +[x "y"] + z = others +``` + +删除配置中的某一项 + +```bash +git config --unset --global +git config --unset --system +git config --unset +``` + +### 2.1.4 谁完成的提交 + +允许空白提交,即没有文件修改的提交 +```bash +git commit --allow-empty -m "who does commit" +``` + +查看git日志,包含作者,提交日期 +```bash +git log --pretty=fuller +``` + +修改最新一条commit的作者指令 + +```bash +git commit --amend --allow-empty --reset-author +``` + +`--amend`表示对最后一个提交进行修补 + + + + diff --git a/welcome.txt b/welcome.txt index 18832d3..fd3c069 100644 --- a/welcome.txt +++ b/welcome.txt @@ -1 +1,2 @@ Hello. +Nice to meet you.