Git Command

git init:初始化Git仓库

git add filename:将文件放入暂存区域

git commit -m “explanation”:将暂存区域文件提交至Git仓库

git status:查看当前状态

git log [–decorate –oneline –graph –all]:查看提交记录

git reset [–mixed(default)/soft/hard] HEAD[~*n]/Git_ID:回滚文件(默认从Git仓库至暂存区域)

git checkout [filename]:回滚文件(从暂存区域至工作区域)

git diff:比较工作区域与暂存区域

git diff HEAD[~*n]/Git_ID:比较工作区域与快照

git diff –cached [HEAD[~*n]/Git_ID]:比较暂存区域与快照

git diff HEAD[~*n]/Git_ID1 HEAD[~*n]/Git_ID2:比较两个快照

git commit –amend:更改最后一次提交

git mv oldname newname:重命名文件

git branch branchname:创建分支

git checkout [-b] branchname:切换分支

git merge branchname:合并分支至master

git branch -d branchname:删除分支

git clone url:克隆云端Git仓库至本地

git push –set-upstream origin master:推送本地Git仓库至云端