I'm still quite new to Git but have thus far been able to figure out how to do what I want to do with some searching. I'm trying to clean up my Git history and remove a previous commit and branch called bootstrap-v4
but haven't had any luck so far. Can someone suggest how to remove the branch and extra commit and keep my master
branch clean?
Asked
Active
Viewed 840 times
1

Liam
- 27,717
- 28
- 128
- 190

tylorreimer
- 79
- 1
- 11
-
Tl;Dr you don't GIT doesn't work like that. A branch is just a pointer on the graph. You can delete the branch (pointer) but all the commits and where they sit remain in the graph – Liam Jul 05 '17 at 14:56
-
Is there a way to roll back the history then and remake the changes? Maybe it's a little OCD but it bothers me having redundant commits or branches that I don't need. I know there are ways to append and change commits to help clean things up. – tylorreimer Jul 05 '17 at 15:05
-
I think what your saying is when you did the merge you should of done a [fast forward merge](https://community.atlassian.com/t5/SourceTree-questions/Is-there-a-way-to-achieve-fast-forward-merge-in-SourceTree/qaq-p/99606). FYI having used several GIT UIs I don't rate source tree. It looks fancy but IMO it's functionality is confusing. If your starting out I'd give [GIT extensions](https://sourceforge.net/projects/gitextensions/) (no affiliation) a go instead. It makes this kind of thing much easier (or better yet learn the GIT command line interface) – Liam Jul 05 '17 at 15:44
-
*Is there a way to roll back the history* Yes, [use `git reset`](https://stackoverflow.com/questions/9301782/need-to-reset-git-branch-to-origin-version) – Liam Jul 05 '17 at 15:46
1 Answers
2
Your GUI is showing you your uncommitted changes, which is the merge of bootstrap-v4
branch to master
. If you do not wish to commit those changes, that is what a git reset --hard origin/master
would accomplish (alas, I am not familiar with the operation of your GUI, but it should offer you some way of doing a hard reset)
As for removing the remote branch, on the command line, it would be: git push origin :bootstrap-v4

Ben
- 1,287
- 15
- 24
-
Thanks Ben, that did the trick! I'm not sure if there was a way to do it in SourceTree but I opted for using `Terminal`. Cheers. – tylorreimer Jul 05 '17 at 15:11