From 62c8729c5ce9f26c80e4dde58ea6f01a2b8adfa5 Mon Sep 17 00:00:00 2001 From: daiwanxing <377099119@qq.com> Date: Mon, 29 May 2023 14:20:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0git=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/articles/git/index.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/articles/git/index.md b/docs/articles/git/index.md index c4b378ba..8bb3ae3e 100644 --- a/docs/articles/git/index.md +++ b/docs/articles/git/index.md @@ -96,7 +96,7 @@ git stash pop # 通过该命令取出暂存了的代码, 执行该命令后, ::: :::tip -如果需要删除暂存得所有记录,可以使用 `git stash clear` 清空栈 +如果需要删除暂存的所有记录,可以使用 `git stash clear` 清空栈 ::: ## cherry-pick @@ -209,4 +209,18 @@ git cherry-pick commit-b ## 交互式 rebase -交互式 rebase 指的是使用带参数 --interactive 的 rebase 命令, 简写为 -i。交互式 `git rebase -i` 会打开一个 GUI 界面。我们可以通过这个 GUI 界面对 要 merge 的 commit 进行排序后,生成一份新的 commit 副本。 \ No newline at end of file +交互式 rebase 指的是使用带参数 --interactive 的 rebase 命令, 简写为 -i。交互式 `git rebase -i` 会打开一个 GUI 界面。我们可以通过这个 GUI 界面对 要 merge 的 commit 进行排序后,生成一份新的 commit 副本。 + +## git 删除所有分支 + +如果想删除所有的分支,(但至少要保留一个分支),那就有个很方便的命令:`git branch | grep -v "master" | xargs git branch -D`,这个 git 命令表示删除本地所有的分支,除了 `master` 分支保留。 + +:::tip +如果在 windows 电脑上,需要打开 git bash,才能执行此命令,无法直接在 `cmd` 或者 `powershell` 上执行。 +::: + +如果希望既保留 `master` 又保留 `develop`,直接再重复输入一次参数就行。 + +```shell +git branch | grep -v "master" | grep -v "develop" | xargs git branch -D +``` \ No newline at end of file