You cannot imagine the amount of patience you'd have to exercise while working on a project as a group if everyone had to wait for the other before they could code their part of the project, trust me, it would be quite tremendous!
Well, all thanks to GitHub, as a platform, that enables developers to work concurrently with each other regardless of the time zone or location in which your team members are.
This has all been made possible by GIT Collaboration.
Wondering how this can be possible, follow through the step by step guide below :
1. Create a new GitHub Repository
This shall have all the project files and history plus the
README file which gives general information of what the
project is about.
Ensure to keep the repository name simple and short as its
easier to remember that way. Plus its best practice.
The repository should be created by one person(scrum-master)
who can add the others as collaborators.
2. Clone the repository onto the local machine
Using the link to the repository, all collaborators added to
the project should clone it onto their local machines.
A point to note is that everyone who has been added as a
collaborator will now be working while on the **main branch**
which and this can cause conflict in due course of the
project.
One should always know the branch in which they are working,
and to do this, in the terminal, run;
git branch -a
(the current branch will appear in green, depending).
3. Create a your own terminal
In due course of the project, all collaborators have to get
their deliverables done and to do this, you must have your
space to write your code before it can be merged to the main
file.
In the terminal, run;
git checkout -b _[name of the branch]_
This will create a new 'workspace' for you as a collaborator
to put your work.
And to ensure that you are on the right track, run the command
in part 2 above to see your new terminal.
4. Track the changes done
First things first, as a collaborator, ensure that your work
is up to date with that of others. To do this, in the
terminal, run;
git pull
This will instantly fetch and download the content from the
remote repository and update the one on your local machine.
Thus implying that all the changes made earlier on will all be
visible not only to you but to the team at large.
That will also enable all collaborators to see their
particular branches.
One should note that as a team, its always wise to have a
Development terminal where the collaborators can first push
their work before it is finally published onto the PRODUCTION
phase.
If that is done, run;
- _git pull development_
(this aligns all your work with that of others on the
development terminal)
- git add .
( this will add a change in the working directory to the
staging area preparing it for the commit upcoming)
- git commit -m"[commit message]"
(this shall capture the snapshot of the project's changes
that have been so far staged)
For the commit message, one out to put in a very brief
description of what they have done just as best practice to
enable keeping of track.
- git push origin [name of branch]
(this will push the current branch to the branch of the
matching name in the remote repository)
In simpler terms, the work on your local machine in the
branch you've been working in will align with that on the
remote branch.
5. Change to the Development Branch
As earlier mentioned in our context, none of the
collaborators is tempering with the main branch. That means
that we all push our contributions to the development branch
first before finally publishing on the production branch.
To do this, run;
git checkout [development]
'git checkout' will enable you to switch working tree files
or switch branches.
As best practice, perform a 'git pull' to be able to get
everyone's contribution and also have the updated version of
their contribution.
6. Merge Your Contribution
In simpler terms, this is supposed to join two or more
development histories together.
To do this, run;
git merge [name of the branch you are working in ]
7. Push all Changes to the Development Branch
This should be done after merging all the changes into the
development branch.
Simply run;
git push origin development
This is done so that the work of all collaborators is in one
place and test before the scrum master pushes to the
production branch.
Please Note:
1.
In the scenario that an error message appears, git pull the branch in which you are working, a new message will still appear in the terminal because the snapshot on the local machine is not aligned with the one on the remote.
However, this can be solved by rebasing it.
Run the command;
git pull --rebase origin development
After the rebase has been made, everything will be updated.
2.
Always while working on group projects, ensure that as you work, you pull from both the development branch and your personal one. And always remember NEVER to push to the main/production branch unless you are told to do so.
Conclusion
If you found this blog post helpful, please consider sharing it with others who might benefit just like you did. You can also follow me for more content in future on JavaScript, React, and other web Development topics.
Also if you think there are any changes that could make the work better, feel free to reach out.
Top comments (0)