![]() There are conventions and processes that are developed to minimize the complexity of multiple developers working on the same codebase, but there are no strict rules except for one. TL DR a suitable branching model depends on a whole lot of things, such as the length of the release cycle, the amount of testing done, the amount of developers and of course the nature of the system. Ideally you wouldn't risk pushing broken code to dev, running tests locally before pushing, but if for example the test set is heavy, it might not be possible. It may also mean that development can be "broken", if the idea is that features are pushed to dev and automated testing is done on that branch when new code is pushed. This may not be an issue, and it may be completely intentional if short release cycles are to be used. ![]() In your first situation you have to make sure that dev and master are synchronized, so you don't test code in dev that would then break in master. Git doesn't mandate that you do things in a specific way, but time has taught effective processes to use. Your first situation describes a different branching model. What I've described is your second situation, which follows gitflow at least in principle. if you have a daily build/release cycle, your master and development will never be very far from each other), but this is one logical reason (and not just a convention) why development should be used instead of master for branch root. There are different factors that affect how much of a difference this makes (e.g. This means you'll have less merge conflicts. Since development will most likely be merged back to master to represent the new "release state", branching off of development allows you to develop on top of more up-to-date code than if you were to branch off of master. This means that 'master' can be seen as a repository's 'default' branch. After cloning (downloading) a project from a remote server, the resulting local repository has a single local branch: the so-called 'master' branch. Since you (hopefully) won't merge directly to master, you could end up developing on top of "stale" code (from master) and when merging to development you would notice that "oh no, I've written code that doesn't fit well with the code in development". In Git, 'master' is a naming convention for a branch. ![]() ![]() On the other hand if you don't release often, and are working with multiple developers, the development branch could contain a lot of changes and be very different from master. This is because master (or trunk or main or whatever it's named) should represent a very stable state of code, ideally the same as the last release. git push origin -delete master Update the upstream remotes HEAD. git push -u origin main Log into the upstream repository host (GitHub, GitLab, Bitbucket, etc.) and change the 'default branch'. Generally speaking if you have a master branch and a development branch, and you're following some process (instead of randomly doing things in git), you are most likely expected to branch from dev instead of master. git branch -m master main Push renamed branch upstream and set remote tracking branch. ![]()
0 Comments
Leave a Reply. |