How to update and maintain separate Git branches

insert image description here
One of Git's core features is the ability to make multiple versions of a project. Typically, these are used for short-term branches called "feature branches" that are merged into the master branch. However, sometimes it is necessary to have truly independent branches, which makes it difficult to keep them in sync.

Why maintain a different branch?

Usually, branches are short-lived and intended to be merged back into the main release branch. But in some cases it is necessary to maintain completely separate branches. For example, you might have branches for different platforms or dependencies, with different features, or just separate release branches that you can keep for a while.

This is the same workflow as most forks, and depending on the number and severity of changes, it can be difficult to keep up with upstream. If your two branches are largely in sync minus a few commits, you'll have an easier time dealing with conflicts and staying up to date.

But in most cases you should look for alternatives to splitting branches, as it can get very tedious, especially with merge conflicts and all the extra testing. For example, if you have two builds for different platforms, many languages ​​have build configurations and preprocessors that can handle it. C# has #if NETVERSION, which allows to change the code depending on the platform it was compiled for.

Guess you like

Origin blog.csdn.net/wlcs_6305/article/details/123294891