For version control, I've been mostly exposed to Mercurial, but want to get better at using Git as well. There's one workflow I'm used to do that doesn't seem to be shown much in the tutorials and examples for Git beginners, namely removing a branch from your repository.
The scenario is this: The master branch has a bunch of commits, and at some point, I made a feature branch for a feature which might be merged in at some point in time. However; the branch was abandoned, and more commits were added to master. Now it's been decided that the development of the features on the feature branch is not needed, and should not be pushed to the central repository. In mercurial, using TortoiseHg, I'd then do the following:
https://i.stack.imgur.com/aT3Ib.png
Whereby commits numbered 4, 5 and 6 are removed from the repo, leaving me with the desired, final repository:
https://i.stack.imgur.com/KEX4j.png
I've tried looking at using git branch -D <branch-name>
, but that doesn't seem to do what I expected it to do. It seems the commits on that branch are retained in the repository, it just removes the branch name.
What's the best/safest/easiest/quickest/name-more-types-here way to achieve that workflow with a Git repository?