Skip to content

Commit

Permalink
11
Browse files Browse the repository at this point in the history
  • Loading branch information
squid-Xu committed Sep 2, 2024
1 parent ce3f665 commit 1a82f6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ export default defineConfig({
collapsed: false,
items: [{ text: 'sessionStorage 能在多个标签页之间共享数据吗?', link: '/summary/browser/No1' }],
},
{
text: 'git',
collapsed: false,
items: [{ text: 'git回滚和强制提交', link: '/summary/git/No1' }],
},
{
text: '其他',
collapsed: false,
Expand Down
17 changes: 17 additions & 0 deletions summary/git/No1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# git回滚和强制提交

- Git回滚代码到某个commit

- 回退命令:

- `git reset --hard HEAD^` 回退到上个版本

- `git reset --hard HEAD~3` 回退到前3次提交之前,以此类推,回退到n次提交之前

- `git reset --hard commit_id` 退到/进到,指定commit的哈希码(这次提交之前或之后的提交都会回滚)

- 回滚后提交可能会失败,必须强制提交

- 强推到远程:(可能需要解决对应分支的保护状态)

- `git push origin HEAD --force`

0 comments on commit 1a82f6c

Please sign in to comment.