一、提交文件方面命令:
1.1第一步:将需要提交的文件放进暂存区:
-
添加单个文件到暂存区stage:
git add 文件名

-
添加多个文件到暂存区:
git add 文件名1 文件名2 ...

-
将目录下所有文件添加到暂存区:
git add .

1.2第二步:将缓冲区的文件添加到版本库:
git commit -m "本次提交方面的详细描述"

1.3第三步:将本地仓库的文件同步至远程仓库:
git push
二、查看仓库信息方面命令:
2.1日期由近到远的打印版本库的提交日志:
-
详细的打印所有信息:
git log

-
以一行的方式打印部分信息:
git log --pretty=oneline

2.2查看工作区和暂存区的状态:
-
查看工作区是否干净,例如文件没有push或commit等:
git status


2.3对比文件在不同区域的差异:
-
暂存区和工作区之间的差异:
git diff 文件名

-
版本库和工作区之间的差异:
git diff HEAD -- 文件名

三、文件版本回退方面命令:
git reset
是一个强大的 Git 命令,用于回退当前分支的HEAD指针到一个指定的提交。
3.1只回退版本库中的版本:
git reset --soft commitID
3.2回退暂存区和版本库中的内容:如果不指定选项,默认使用mixed
git reset --mixed commitID
3.3回退三个区域的内容:
git reset --hard commitID
案例分析:使用hard需要谨慎



3.4找到曾经存在的提交记录:
-
Git Reflog 是 Git 的一个工具,用于记录所有对仓库的引用(ref)的更改。即使在引用被移动或删除后,Reflog 也能帮助你找到那些曾经存在的提交记录。
git reflog

- 使用git reset --选项 ID,可以回到指定节点。