建站提交历史文章,原文写作时间 2023 年 1 月 11 日前后。
Get Start
开始之前创建一个文件夹,这里以 user/jamhus_tao/test 为例。
| 12
 3
 4
 5
 
 | cd user/jamhus_tao/test     git init
 git status
 git add readme.md
 git commit -m "This is my first commit"
 
 | 
后文会大量提到分支的概念,这个在另一篇文章中提到,默认分支为 master。
比较
| 12
 3
 4
 5
 6
 7
 8
 
 | git status                    git status {file}
 git diff
 git diff {file}
 git show
 git show {id}
 git show {branch}
 cat {file}
 
 | 
更新
| 12
 3
 4
 5
 6
 
 | git add {file}                git add {file1} {file2} ...
 git add -A
 git commit -m "This is my first commit"
 git commit -a -m "The second commit"
 git rm --cached {file1}
 
 | 
查看记录
| 12
 3
 4
 5
 
 | git log                             git log --pretty=oneline
 git log --pretty=oneline --graph
 git log {branch}
 git log --pretty=oneline --graph {branch1} {branch2} ...
 
 | 
| 12
 
 | git reflog                git reflog <branch>
 
 | 
版本滚动
| 12
 3
 4
 5
 
 | git checkout -- {file}         git reset --hard HEAD
 git reset --hard HEAD^
 git reset --hard {id}
 git reset --hard {branch}
 
 |