回到某次commit
-
保留提交记录
git reset --soft commitId(可通过git log 找到对应的commit)
-
丢弃提交记录
git reset --hard commitId
补丁包使用(patch)
将项目的某次commit 生成一个文件,通过这个文件可将commit 的代码提交到另外一个人的项目里
- 打补丁:git format-patch commitId
- 使用补丁:git apply 生成的文件名
暂存代码(stash)
解决冲突或不想提交到线上使用,当本地代码和线上代码冲突时,可先将本地代码暂存,拉取线上代码后再取出来
- git add .
- git commit -m xx
- git stash
- git pull
- git stash pop