5

I'm working on a small project, and I am using Github as version control. I made a new branch to test something out, and have decided I liked the previous method better (in the master branch).

What is the intended paradigm for branches in git? Do they denote that a different attempt was made, and it was not used (if the branch was not merged), or would it imply that more work is being done in that direction?

My more practical question is: Should I just delete the branch, or can I just leave it there (as I'd like to leave the "test" code there, in case I need it later)?

3
  • Perhaps you can rename the branch or add a last commit with a comment that this is a 'dead' branch and why you don't continue to use it.
    – knut
    Commented Apr 7, 2015 at 18:37
  • 1
    How exactly branches are used in your organization will vary. The only 'paradigm' is that they are a separate line of work. Why they were created, what purpose they serve, when and how they are merged into other branches such as master will depend on your organization as there are several models. Commented Dec 1, 2016 at 14:21
  • Archive the tip of the branch with a tag. Then delete the branch. Commented Apr 28, 2023 at 8:21

2 Answers 2

3

The new Branch wont interfere on the master branch You should leave it there and keep writing and commit on the master branch

2
  • Ok, thank you so much! In the case that you're wrong, I'll just wait a little while longer, but after that I'll accept yours :).
    – Numeri
    Commented Apr 7, 2015 at 16:46
  • 1
    If you want the code later you can just leave the branch hanging out there and nothing will happen. I have some branches in a repo that have not had a commit on them for 3 months because priorities changed. Eventually (hopefully) it will get more work on it. If the feature is canceled we can always delete it then. Commented Apr 7, 2015 at 18:30
0

Pushing straight to the integration branch can make it hard to determine the beginning and end of independent features or bug fixes. Better to branch off for each of those, then merge back into the integration branch without fast forward.

You can use master as your integration branch but a common model is to use that for production ready code and create another branch e.g. 'develop' as as integration branch.

You can leave your trial branch in place or make a note of the commit hash and then delete it. Either way you will be able to get back to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.