Let me show you an example of three co-workers (persons) working on the same project (using git). To minimize the effort of merging, it is recommended to use a separate branch for each worker. For example:
For worker 1 branch: test1
For worker 2 branch: test2
For worker 3 branch: test3
And the end of the day every worker commit and push to it’s branch on origin:
Worker1:
git add -A git commit -m "Message" git push origin test1
Worker 2:
git add -A git commit -m "Message" git push origin test2
Worker 3:
git add -A git commit -m "Message" git push origin test3
Now, one worker (for example worker 1) need to merge all the three branches into the master. First he need to retrieve all the changes of the branch:
git checkout test1 git pull origin test1 git checkout test2 git pull origin test2 git checkout test2 git pull origin test2 /*In case something went wrong and there are so merging conflict, just use the following command to take the remote version:*/ git reset --hard origin/master
And here comes the merging:
git checkout master git merge test1 git merge test2 git merge test3 /*In case of merging conflict, just resolve them in the file and than commit the changes.*/
Now when all the branches are merged, just upload the result to the origin master:
git push -u origin master
Here we are: The co-workers now need only to retrieve the last code from the origin repository:
For worker 1:
git checkout test1 git pull origin master
For worker 2:
git checkout test2 git pull origin master
For worker 3:
git checkout test3 git pull origin master
And this is it. Enjoy coding.