git常用命令 功能代码返回结果git status文件状态git status -s返回简洁文件状态清空终端clear查看文件状态git status --short 和-s一样跟踪新文件git add index.htmlchanges to be commited (new file)已被跟踪处于暂存状态绿色A暂存已修改文件git add index.htmlchanges to be commited (modified)绿色M提交更新git commit -m "描述消息"Nothing to comit, working tree clean已经提交跳过暂存 将跟踪的文件暂存并提交git commit -a -m "描述消息"加一个-a撤销对文件的修改git checkout -- index.html用git仓库中的文件覆盖现有文件–和文件名间有空格向暂存区放多个文件git add .从暂存区移除文件git reset HEAD index.html从git仓库和工作区同时移除文件git rm -f index.html只从仓库中移除文件git rm --cached index.html查看提交历史git log查看最新两次提交消息git log -2在一行上展示最新两次提交消息git log -2 --pretty=oneline版本回退git reset --hard <CommitID>例:git reset --hard fae1cd7在旧版本中查看所有提交历史git reflog --pretty=oneline 文件状态返回结果简洁结果说明未被跟踪时untracked红色??新文件刚被跟踪并存入了暂存区绿色A修改后modifiedchanges not staged for commit红色M跟踪文件内容发生变化但没放到暂存区暂存后绿色modified绿色M 修改文件后将文件放入暂存区,状态由红M(已修改)变为绿M(已暂存):