Anthony De Smet
Anthony De Smet

Reputation: 2395

Created an unwanted branch in git, want to get rid of it

JIRA created a branch for a feature I was working on, but I don't want it. I'd like to move all the changes I've made so far back to the master branch and simply remove the feature branch altogether. Can anyone help me?

I just want one simple master branch on top, where the ANDROIDAPP-137 is now.

Upvotes: 1

Views: 77

Answers (2)

criswell
criswell

Reputation: 789

If I'm reading your log correctly, it seems all you need to do is a rebase/merge and you'll be good to go:

git checkout master
git rebase ANDROIDAPP-137-actions-are-slow
git branch -d ANDROIDAPP-137-actions-are-slow

If rebase doesn't work, do a merge instead.

For more on git branching check out the documentation on it.

Upvotes: 1

Chris Maes
Chris Maes

Reputation: 37742

First let's make sure what this is going to do:

  1. move your commits on branch ANDROIDAPP-137-actions-are-slow to master
  2. completely remove (locally and remote) ANDROIDAPP-137-actions-are-slow branch

first get back to master:

git checkout master

now get the work from your branch; rebase onto that branch:

git rebase ANDROIDAPP-137-actions-are-slow

now your commits should be on both master and ANDROIDAPP-137-actions-are-slow branch, you can check with:

git log --all --graph --decorate --oneline

so you can remove the jira branch:

git branch -D ANDROIDAPP-137-actions-are-slow

and remove it remotely:

git push origin :ANDROIDAPP-137-actions-are-slow

Upvotes: 3

Related Questions