0

So far I've only used git for solo projects, but for last we days I've been working with a friend on a team project, but the branching kinda confuses me.

When I was working on a new feature (based on an issue), I created the branch from within the issue. Then I fetched it using

git fetch

I started working on the branch by doing

git checkout featurebranch

and doing my part of coding. After I was done, I commited the changes and pushed them to the branch

git commit -m ...

git push

after that, I created a merge request on the gitlab page and approved the merge with an option to "remove the branch after merging" selected

The branch got merged and deleted from the remote repository. I checked out back to master, however when I do

git branch --list

I can still see master & featurebranch. How do I delete the featurebranch from my local repo? What's the proper way of handling branching, so no "leftovers" stay in the repo?

SEnergy
  • 47
  • 1
  • 11
  • 1
    Possible duplicate of [How do I delete a Git branch both locally and remotely?](https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-remotely) – phd Sep 15 '18 at 15:52
  • no... 15 char ftw – SEnergy Sep 15 '18 at 22:52

1 Answers1

1

"remove the branch after merging" function only removed branch in GitLab server's repository.

But you have one default remote origin and one local branch.

  1. To remove branch on remote origin in your local repository, you should execute git fetch --prune to prune deleted branches on server.
  2. To remove local branch which you checkout before, you should use git branch -d featurebranch to remove it.
networm
  • 349
  • 2
  • 4