Should a Git branch contain experiments you never plan to merge?

0
0
Asked By MellowQuartz47 On

After creating a personal branch for a Git project, is it okay to commit prototypes, debugging changes, or other experiments that will never be merged into the main branch? If those changes should stay local, what is the usual workflow for keeping them around without accidentally including them in a pull request?

2 Answers

Answered By SilverPine32 On

For changes that are only temporary or machine-specific, use .gitignore for files Git should never track and stash for work you want to set aside briefly. If the experiment is worth preserving, commit it on a local-only branch. Just remember that anything committed on a branch can become difficult to merge later if the main codebase changes significantly.

Answered By CedarFox8 On

A branch is yours to use however you want, especially if it stays local. The important distinction is whether you push it or open a pull request. A pull request compares your branch with its target branch, so unrelated commits and changes can make the review confusing. For experiments, keep them uncommitted, stash them, or create a temporary branch that you never push.

MellowQuartz47 -

So before opening a pull request, would I need to manually remove anything experimental from the branch?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.