In development teams its quite common that the team avoids (or even prevents) pushing directly to the main branch. The idea is that before one developer can add their code to the main, the team will check the code and then either accept or deny merging it to main. The purpose is to keep the main clean from bugs.
When developer starts to add some new features, they will create a new branch for that. Then they will push to GitHub that branch quite often (example once a day). And when the feature is ready the want to merge it to the master. But instead of merging it by themselves, they can create a pull request in GitHub. Then the team will check the code and decide if they accept that pull request or not. If they accept, someone of them will merge the branch to the main. After that every member should pull the latest version of main to their local repo and then merge the main to the branch that they are working with.
To make the pull request in GitHub, you should click the text Pull request and you will see this
When you click the button New pull request, you will see this
And now you should check that the branches are what you want and that the arrow is on the right direction (in the image from nametest to main)
When someone else in your group signs in to GitHub, they will see your pull request. And then they should do this
Now you should inform all your collaborators that they should "upload" the latest main.
So, let's assume that you are working with a branch named
Then you should do this:
Let's assume that in the branch beaver file test.php line 3 is like this:
echo 'Welcome Jim';. And you pulled the new version where the same line is this:
echo 'Welcome Ann';. So, when you execute the command
git merge main,
you will get an error message:
Auto-merging test.php CONFLICT (content): Merge conflict in test.php Automatic merge failed; fix conflicts and then commit the result.And when you open the file, you will see this:
<<<<<<< HEAD echo 'Welcome Jim'; in beaver ======= echo 'Welcome Ann'; in login_system >>>>>>> mainSo, you have to edit the file. And you decided to edit the previous part like is this:
echo 'Welcome Ann and Jim';Then you hav to do this:
All developers will clone the repo. And then they have to create a new branch.
When you start to make a new "Feature" to the app, create a new branch.