Git: Apparently simple branching issues

I have been using Git for my version control for a while, but so far I have only one master branch for my entire development. As my projects get bigger, I have to worry about stable development branches and release tags.

I read a bunch of articles on Git forking, but I can't figure out how they work, and it makes me a little disappointed when trying to properly configure my branches.

Here is my situation: I have a project that is a set of rake tasks specific to creating our site on a specific server. We are currently using a Debian-based system, but we are going to upgrade to a Ubuntu-based system, so I would like to fork out my project and create a separate branch for each server distribution, and I would like each branch to be able to It's easy to fetch all common code changes from the main branch when I run git pull on any branch. From what I read, this can be achieved by tracking the main branch, but I cannot get it to work correctly.

In addition to this, I also need to start implementing a version of another project so that I can release it, but I don’t know the standard way of Git to achieve this. In my old company, we used TFS (which I hated), and it was pretty simple: we would create a branch from the master and name it "Version 2". Then we made sure that version 2 will be stable and fix any errors, and then all so often, we will merge the changes of version 2 back into the main branch. Is this a Git way to achieve this, and if so, how exactly do I do it?

So, to wrap up, I ask the following two separate (but very related) questions:

  • How to create a remote branch (in GitHub) that automatically tracks changes in master so that I can run git pull in a new branch and make any changes to the wizard; and
  • What is the best method for version control of my project, and can you give some example commands?

Thank you very much, and please let me know if something needs clarification!

+4
source share
1 answer

If I understand you correctly, I don’t think you are tracking correctly. Tracking is used, for example, to track the differences between a local branch and a remote copy of the same branch. Your "version 2" branch should not be tracked by the wizard. Your local master should keep track of the source / master (remote repo).

Instead of tracking (if I understand you correctly), you should use rebase. When the wizard has new corrections that you want in your version 2 branch, then you do (if you are currently in version 2 branch):

git redirect master

and hope that there are no conflicts for you. Rebasing may be another feature of worms, but it's really nice. I used only git for about 6 months, only at work, and after the initial hump I swam smoothly.

+3
source

Source: https://habr.com/ru/post/1304590/


All Articles