Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is better to branch or fork a Mercurial repository?

Tags:

Assuming you "own" a Mercurial repository is it better to branch or fork the repository when embarking on experimental code?

In my situation I'm a lone developer and about to embark on some experimental code. I expect this experiment to take 4 to 6 hours. If I consider the experiment a failure then it highly unlikely I will ever want to refer to it again.

I commit often and push regularly. During the experiment I could only commit and then toss the local repo. However I push regularly mainly as means of backup. The repository is hosted on bitbucket.

In this situation am I better to branch or fork the repository?

like image 294
Tim Murphy Avatar asked Apr 16 '11 06:04

Tim Murphy


People also ask

Is it better to fork or branch?

A branch-centric workflow makes sense for most business settings. Forks can be a really good pattern for 'public' collaboration and experimentation, but when the intended use case is many people working toward a unified goal, branching tends to be a better fit.

When to use branching vs forking in git?

Branching is to create another line of development in the project without affecting the main branch or repository. Forking, on the other hand, is to make a clone of the repository on your GitHub account without affecting the main repository.

When should you fork a repo?

Forking a repository allows you to freely experiment with changes without affecting the original project. Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea.


2 Answers

Being a fan of named branches for all work (branch-per-task, etc) I would recommend ... do both.

Clone the original repo, and in the new repo create a new named branch for the experimental work.

If you decide to keep the experimental work, push it back to the original repo (perform merges as appropriate).

If you decide not to keep the experimental work, just throw the experimental repo away.

like image 161
Tim Delaney Avatar answered Oct 13 '22 22:10

Tim Delaney


If I consider the experiment a failure then it highly unlikely I will ever want to refer to it again.

You answered your own question, fork it locally then pull your changes in the main repository if successful.

Though I don't think you would generate too much content in 4 to 6 hours that would make a useless branch bothersome...

like image 35
Toni Ruža Avatar answered Oct 13 '22 22:10

Toni Ruža