吴华锦

Git异常处理

2023-02-19

本地工作区文件恢复

git checkout <filename/dirname>

远程分支删除后,删除本地分支及关联

git branch --unset-upstream <branchname>

git branch --unset-upstream feature/test

修改提交时的备注内容

git commit --amend

git log --pretty=online

修改分支名

git branch -m <oldbranch> <newbranch>

git branch -m feature/stor-13711 feature/story-13711

撤回提交

git reset --soft [<commit-id>/HEAD~n]

git reset --soft HEAD~1

git reset --mixed HEAD~1

git reset --hard HEAD~1

撤销本地分支合并

git revert <commit-id>

恢复误删的本地分支

git checkout -b <branch-name> <commit-id>

git checkout -b feature/delete HEAD@{2}

不确定哪个根治有自己提交的commit

git branch --contains <commit-id>
Tags: Git
使用微信打赏 使用支付宝打赏

雅致寓于高阁渔舟唱晚,古典悠然;
格调外发园林绿树萦绕,馥郁清香。

扫描二维码,分享此文章