Proper workflow using git and github

So, I'm currently coding rail applications using git and github. I usually work alone, but in my last project I work with a second developer. I am trying to figure out standard methods for working with another user.

Currently, I made him crush my gitrepo, and then just send pull requests when it has changes. This was not so bad, except that I code a lot more - and when there are changes in the queue on the fork queue, many of them fail (even if he did not make any changes the last time, he clicked mine).

The whole process just seems more effective for him to shout every time, which makes me think that we are doing something wrong. Should we use branches instead of forks? Or maybe forks and branches?

Thanks!

+4
source share
2 answers

The second developer should first bring the GitHub repository to their local repo, resolving any conflict there.

And then he can make pull requests.

  • No need to shout down (this makes no sense: "fork" is a clone on the GitHub side)
  • there is no need for an additional branch (if you both work for the same set of functions, you can work as, for example, master )

The idea of ​​a transfer request remains to send patches that will be quickly forwarded (easy to apply to your GitHub repository).
And this is achieved by resolving any conflicts locally first, before making a pull request.


Other options are to declare the second developer as a “co-author” in your GitHub project (he could click directly), but that would not change the fact that “pulling out the first” is necessary to ensure that the push will be simple.

+1
source

There are several git workflows because it is a flexible tool, but a simple workflow is to have a master branch and a develop branch. You can simultaneously push and pull directly to your repo without forking on github and without having your employee constantly send Github requests.

You can make most of your local commits in the development branch, but often exit the remote development branch to merge the code with each other - at this point you can deal with merge conflicts before clicking on the remote one.

Less often, you can pull out a wizard and merge it using development. The idea is that the main branch is more stable and can be prepared for release at any time, so there is no active development on it. That is all that is needed.

If you want to go further, you can make "function branches" from your development branch, but the principle is the same - merge back up to develop, and from there "up" to master.

It is important to synchronize (combine) your work often, otherwise the differences in your individual copies of the code base are likely to be larger, which means a greater chance of conflict. If you still have conflicts, click and drag more often so that the differences are smaller and easier to handle.

Conflicts are especially likely if you both work hard with the same files. In such cases, sometimes it pays for the organization and division of work into functions that change different parts (files) of the code base, so you are less likely to step on each other.

Do not forget to commit local changes before pulling, otherwise the changes will be considered to be in the "setting" and will not be automatically combined during pulling. Fortunately, git is quite forgiving and very good at merging conflicts.

+1
source

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


All Articles