git (记得完善哦,好的)

261 阅读1分钟

git add file.vue wc 添加到stage中

git checkout file.vue 从stage 中还原文件到wc 中

当我们想要对上一次的提交进行修改时,我们可以使用git commit –amend命令。git commit –amend既可以对上次提交的内容进行修改,也可以修改提交说明。

git add .
git ci 'A' #A
//做一些修改
git add .
git commit --amend
此时会进入填写 commit msg 界面,其中内容为 'A'
完成后 #A的提交记录消失, 代之以新的提交

git reset index.vue

将history 中的内容覆盖到stage 中,同时原先stage中的内容失效变成没有staged 假如在上次add 后 index.vue 又修改了,但没有add. 此时如果通过checkout 从stage 中捞数据,将会导致wc 中的修改丢失.

git reset index.vue 全称是 git reset --mixed HEAD index.txt

git checkout HEAD .

wc 和stage中所有的「修改」都会被撤销,恢复成HEAD指向的那个history commit。

git checkout $hash somefile

hash:空时将从stage中捞数据到wc:非空时将hash : 空时 将从stage 中捞数据到wc中 : 非空时将 hash 中的内容捞到 wc 和stage中,二者原先的内容消失

git reset $hash 合并多个

从结果来看, 会合并 HEAD ~ hash+1这一段commithash + 1 这一段 commit 而 hash 不变 也即合并$hash 以上的部分 此时可以通过 git reflog 来查看所有的提交记录

关于reset

撤销工作区修改

git checkout --

暂存区文件撤销 (不覆盖工作区)

git reset HEAD 版本回退

git reset --(soft | mixed | hard ) < HEAD ~(num) > |

--hard : all , including, HEAD ,index && working tree --mixed : partly reset including HEAD ,index --soft : only HEAD

指令作用范围--hard回退全部,包括HEAD,index,working tree--mixed回退部分,包括HEAD,index--soft只回退HEAD