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?
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.
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.
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.
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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With