https://learngitbranching.js.org/
https://backlog.com/git-tutorial/cn/stepup/stepup7_1.html
git clone ……
git add README.md
git commit -m "add README"
git push

git add .
git checkout a.txt
git commit -m '一些描述'
git commit --amend # amend把修改和之前的那个 commit 中的修改合并,作为一个 commit 提交到 history 区
git reset a.txt
git reset --mixed HEAD a.txt
# 不改变 work dir 中的任何数据,
# 将 stage 区域中的 a.txt 文件还原成 HEAD 指向的 commit history 中的样子。
# 就相当于把对 a.txt 的修改从 stage 区撤销,但依然保存在 work dir 中,变为 unstage 的状态。
git commit -a # 快捷方法
git checkout HEAD .
# work dir 和 stage 中所有的「修改」都会被撤销,
# 恢复成 HEAD 指向的那个 history commit
$ git reset 17bd20c
$ git add .
$ git commit -m 'balabala'
# 相当于把 HEAD 移到了 17bd20c 这个 commit,而且不会修改 work dir 中的数据,所以只要 add 再 commit,
# 就相当于把中间的多个 commit 合并到一个了。
git reflog
创建分支
git branch (branchname)
git checkout (branchname)
git checkout -b (branchname) # 创建新分支并立即切换到该分支下
显示分支
git branch
git branch -d (branchname)
分支合并
(A)git merge B 把B合并进A
#修改冲突的文件内容,重新提交。
git add .
git commit -m ""
(A)git rebase B 把A合并进B
#修改冲突的文件内容,重新提交。
$ git add myfile.txt
$ git rebase --continue
# 取消rebase,指定 --abort选项
切换分支
git log
git checkout HEAD^
git checkout HEAD~2
移动分支commit
git branch -f master HEAD~3 # 移动master到HEAD~3
git revert # 创建一个新commit head前进

git reset (HEAD^) # head回退

git cherry-pick Y # 将Y commit添加到当前分支

改写提交的历史记录
git rebase -i HEAD~4 # 要改变倒数第4次后的提交
汇合分支上的提交,然后一同合并到分支
git merge --squash issue1