Git实用命令

撤销commit消息保留修改

git reset --soft [commit_id]

暂存修改

git stash
git stash apply
git stash list
git stash pop
git stash clear

删除恢复分支

# 删除分支
git branch -d <branch_name>
# 恢复分支
git branch <branch_name> <hash_val>
# 查看散列值
git reflog

git pull 强制覆盖本地文件

git fetch --all  
git reset --hard origin/<branch_name>
git pull

拉取远程分支到本地

git checkout -b <branch_name> origin/<branch_name>

合并某一次提交(cherry-pick)

git cherry-pick [<options>] <commit-ish>

从命名树创建文件的存档(git archive)

# 以当前分支打包代码
git archive -o test.zip HEAD
# 以master分支打包代码
git archive -o test.zip master