然后我在本地删除了一个分支为什么这个分支仍然在 github

Then I removed a branch locally why this branch still works on github

这是关于 Git 和 GitHub 的基本新手问题。我只是想确保我做对了。我的项目有一个本地 Git 和一个 GitHub 存储库。我有 Master 和 Develop 分支,我创建了一个新分支然后我在本地删除了一个分支为什么这个分支在 github.

上仍然有一个活动分支
CORP+son.ngoc.ng@son-ngoc-ng01 MINGW64 /d/Project/... (son.ngoc.ng)
$ git checkout son.ngoc.ng
Already on 'son.ngoc.ng'
Your branch is up to date with 'origin/son.ngoc.ng'.

CORP+son.ngoc.ng@son-ngoc-ng01 MINGW64 /d/Project/... (son.ngoc.ng)
$ git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 47 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

CORP+son.ngoc.ng@son-ngoc-ng01 MINGW64 /d/Project/... (master)
$ git branch -D son.ngoc.ng
Deleted branch son.ngoc.ng (was 40b60e8a).

CORP+son.ngoc.ng@son-ngoc-ng01 MINGW64 /d/Project/... (master)
$ git checkout son.ngoc.ng1
Switched to branch 'son.ngoc.ng1'

Git集线器概览


Default branch
master          Updated 3 hours ago by son-ngoc-ng      Default

Your branches
son.ngoc.ng1    Updated 3 hours ago by son-ngoc-ng              #55  Merged
son.ngoc.ng     Updated 4 hours ago by son-ngoc-ng              #54  Merged

Active branches
son.ngoc.ng1    Updated 3 hours ago by son-ngoc-ng              #55  Merged
son.ngoc.ng     Updated 4 hours ago by son-ngoc-ng              #54  Merged

请参考以下步骤删除远程和本地分支:

正在删除 git

中的本地分支
$ git branch -d feature/login

正在删除 git

中的远程分支
$ git push origin --delete feature/login

如果您在本地存储库中删除了一个分支,这并不意味着它将自动从 GIT 中删除。要从 git 中删除 if,请转到以下文档:

https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository

因为您可能已经将新创建的分支推送到远程 github。所以你必须删除远程和本地分支。如果您还没有将您的分支推送到远程 github,那么删除本地分支将起作用。