git笔记:git reset、git rebase 编辑已推送到远程的commit,例如回退到某一次commit提交

git fetch 先将本地与远程同步

git pull

git status 确认无待提交项

git remote -v查看远程仓库

git branch -a查看分支,包括本地及远程分支

git checkout -b [branch]切换到[branch]

git checkout -b [local branch] [remote]/[remote branch]将远程分支拉取到本地

git log 查看git log中所有的commit,复制将要操作的commit ID

git reset --hard [commit ID] 仅需回退版本用git reset,回退到此commit,不保留之前的文件

git reset [commit ID] 保留之前的文件,回退到此commit。

git rebase -i [commit ID] 变基操作 https://git-scm.com/docs/git-rebase

pick:保留该commit(缩写:p)
reword:保留该commit,但我需要修改该commit的注释(缩写:r)
edit:保留该commit, 但我要停下来修改该提交(不仅仅修改注释)(缩写:e)
squash:将该commit和前一个commit合并(缩写:s)
fixup:将该commit和前一个commit合并,但我不要保留该提交的注释信息(缩写:f)
exec:执行shell命令(缩写:x)
drop:我要丢弃该commit(缩写:d)回退到某次commit就用这个命令把前面的全部弃用

保存并退出的键盘操作ctrl+o,enter,ctrl+x

git push --force-with-lease [remote] [branch] 强制推送到远程仓库

posted @ 2022-05-24 17:51  wind-stormger  阅读(292)  评论(0编辑  收藏  举报