比较暴力的方法
git reset --hard <commit-id> git push <reponame> -f # 这样会消除截止到回溯版本的历史记录
比较温柔的做法
# Reset the index to the desired tree git reset 56e05fced # Move the branch pointer back to the previous HEAD git reset --soft HEAD@{1} git commit -m "Revert to 56e05fced" # Update working copy to reflect the new commit git reset --hard
更详尽内容
http://stackoverflow.com/questions/1895059/revert-to-a-commit-by-a-sha-hash-in-git
回溯之后其他已更新的代码库pull代码
git fetch --all git reset --hard origin/master
更详尽内容
http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull
忽略版本库里面的文件
# 忽略已经在版本库中的文件 git update-index --assume-unchanged PATH # 在PATH处输入要忽略的文件。 # 取消忽略 git update-index --no-assume-unchanged PATH