2

This is a basic newbie question about Git and GitHub. I just want to make sure I'm doing it right. I have a local Git as well as a GitHub repo for my project. I have Master and Develop branches , I created a new branch then I removed a branch locally why this branch still have an active branch on 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'

Github Overview


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

3 Answers3

1

Please refer to the below steps for deleting both remote and local branches:

Deleting local branches in git

$ git branch -d feature/login

Deleting remote branches in git

$ git push origin --delete feature/login
1

If you remove a branch in your local repository, that not means that it will be automatically removed from GIT. To delete if from git, go to the following documentation:

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

bakerwitz
  • 48
  • 3
  • 8
1

Because you might have already pushed your newly created branch into remote github. So you have to delete both remote and local branch. If you haven't pushed your branch into remote github yet, then deletion of local branch will work.