生存必备
git initgit add <file1> <file2>git add .git add -Agit commit -m "xxxxx"git log or git log --pretty=onelinegit statusgit diffgit diff HEAD -- <file> 查看工作区文件和最新版本的区别
分支
git branch list all branchgit checkout -b dev create a new branch and checkout it, or
git branch dev
git checkout dev
git merge dev merge to master and delgit branch -d dev del dev
忽略已提交的文件
git rm -cached <file>- update
.gitignoreand commit it
版本回退
git reset --hard <commit_id>(HEAD~1)git reflog 查看历史命令
撤销修改
git checkout -- <file> 用repo的文件覆盖工作区的文件git reset HEAD <file> unstage, 从HEAD复制文件到index
删除文件
git rm <file>
git commit -m "del <file>"
修改最后一次提交的说明信息
git add <file> # optional
git commit --amend -m "xxx"
tag
git tag 列出taggit show <tag name>git tag <tag name> 在当前commit上打标签git tag <tag name> <commit_id> 在指定的commit上打标签git tag -a <tag name> [-m "xx" | <commit_id>] 带说明(annotation)的taggit tag -d <tag name>