Working together on a project

Written on 14th November 2020

Even though the title talks about making code contributions, this note can serve as a primer to basic git commands. The git commands in this notes are agnostic to what version control server (Github, Bitbucket, etc) you use.

One reason we need to git is so that we can track who made what changes and which files (and lines in a file) were changed. Using traditional folder sharing won't bless you with these. Also git allows us to make contributions to the same file independent of each other and then merge the changes later.

Git is not Github. Git is a version control system. Github is a VCS server.
Read more

Branch out 👉🏽

First thing to do after cloning the repository is to branch (out of master) into a branch of your name or nickname.

git checkout -b notgr
User lowercase alphabets, with hyphens or underscores for the branch name. No spaces should be in the name

This is where you work. And this is how your colleagues can identify your work.

To clone a repo, run git clone <repo-url>. You can get the repo url from the project on Github, Bitbucket, etc.

Get to work!

It is advisable that you make reasonable amount of code commits. What this means is that, when you implement a working feature of problem, save it to git.

To commit run the following commands

git add .
This stages (or adds) your edits for commit (or saving to git)

git commit -m "Search bar implemented."
This is like giving everyone a hint on what you worked on in this commit.

Now your changes are committed. You can choose to keep working and adding more commits or submit your changes to remote.

Remote is the server where you host your git/code files. Github for example.

Submit!

If you're confident you've made enough progress to share for review, run the following command.

git push origin notgr
Remember notgr is the branch name. Which could be your nickname, etc.

After pushing you will find a link in the terminal along the lines of Create a pull request. Click this link to open a pull request form.

Harrgh! Pull request? 🤕

Yes, pull request. You thought we were done?

Use this form to notify your colleagues of the changes you've done. Pull requests are also an opportunity for your colleagues to review your work and provide feedback. If your contributions are fine, then the project leader can merge your contribution into master and probably get you a bottle of Coca-cola.

Last one. Pull!

After you get notified your code was merged to master. Run the following command, after you have committed local changes on your branch.

git pull origin master
This may result in some conflicts. Take the initiative here!