A
A
AlShest2020-11-16 18:26:29
git
AlShest, 2020-11-16 18:26:29

What is the correct way to collaborate and update the master branch?

Hello!
I'm not sure how to properly organize the work with the repository if you have to make a lot of small changes and still avoid conflicts? The commits were asked to be uploaded via a pull request. There are two permanent branches, where master is the working "final" version and develop is the change branch. Let's say when you need to make an edit:
go to the develop branch with git checkout >
then git pull to get updates >
then make your changes to the code >
then git add . and git commit to commit the changes >
then git push -u -origin develop to push the changes >
Then prepare a pull request on github and that's it? Then the main owner will take over the changes and master will be updated?
It's better not to touch the master itself? And is it possible to do this several times in a row if you need to add more edits?

And if there is still permission to independently update master, then how to transfer changes to it from develop? With checkout develop "changed files", commit and push?

Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VicTHOR, 2020-11-16
@AlShest

Let's say when you need to make an edit:
go to the develop branch with git checkout >
then git pull to get updates >
then make your changes to the code >
then git fetch origin masterto pull the changes from the master, if any. Then resolve conflicts, if any. and then commit and push.
Then we prepare a pull request on the github and that's it? Then the main owner will take over the changes and master will be updated?
Yes
It's better not to touch the master itself?
do not touch if not the owner
And is it possible to do this several times in a row if you need to add more edits?
need
And if there is still permission to independently update master, then how to transfer changes to it from develop? With checkout develop "changed files", commit and push?
no, what a horror. It should be done git merge developif there are no conflicts - all commits from the develop branch will simply be pulled into the master and it will be up to date. And thanks to the merging, it will be clear that where from where the code was taken, and when git checkoutthe branches will not be connected.
How to work together the right way
make different branches for development

S
SagePtr, 2020-11-16
@SagePtr

Through a pull request, for each change, create your own branch from the develop branch, commit and push it, and submit it to the pull request. The original master and develop branches should not be changed manually, they are added by accepting a pull request by those who are responsible for this in the project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question