1. 修改最后一次提交
使用命令:
git commit --amend
加上--amend相当于使用暂存区域快照提交。
git commit -m 'first commit'
git add some_file
git commit --amend
最终只产生一次提交
2. 取消对文件的修改
使用命令:
git checkout -- filename
3. 取消已经add的文件
git reset HEAD filename
4. 取消已经commit的文件
git reset <commit_id>
可以加参数--soft,--mixed或--head。默认为--mixed
--soft:只回退commit信息
--mixed:保留源代码,回退commit和index信息
--head:回退源代码
5. 删除已经push
git revert <SHA>
1262

被折叠的 条评论
为什么被折叠?



