Working together on a projectWritten 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
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
Branch out 👉🏽
First thing to do after cloning the repository is to branch (out of
master) into a branch of your name or nickname.
User lowercase alphabets, with hyphens or underscores for the branch name. No spaces should be in the name
git checkout -b notgr
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
This stages (or adds) your edits for commit (or saving to git)
git add .
This is like giving everyone a hint on what you worked on in this commit.
git commit -m "Search bar implemented."
Now your changes are committed. You can choose to keep working and adding more commits or submit your
Remote is the server where you host your git/code files. Github for example.
If you're confident you've made enough progress to share for review, run the following command.
Remember notgr is the branch name. Which could be your nickname, etc.
git push origin notgr
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
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.
This may result in some conflicts. Take the initiative here!
git pull origin master