DEV Community

Samuel Grasse-Haroldsen
Samuel Grasse-Haroldsen

Posted on

Version Control - A Central Tenet In Software Development (Part 3)

Part 3

This is part 3 of my series of blogs on git. Here are the links to the first two installments: Version Control - A Central Tenet In Software Development (Part 1) and Version Control - A Central Tenet In Software Development (Part 2). In this installment I'll be going over how to collaborate with others using git and GitHub.

Working with Others

One of the most important parts of software development is working with others. It is the reason version control software was created. We can easily and consistently work on the same project simultaneously as long as we remember proper git etiquette/protocol. We will also need a service to host our repo(s). I use GitHub.

GitHub

GitHub has a ton of cool features! I could write a whole series on GitHub alone, but for the scope of this article I just want to give a quick overview on how to invite people to contribute to a repo. We can invite as many collaborators as we want to our public and private repos even with a free account. This will allow others to work on projects with us!

  1. Go to the chosen repository's main page on GitHub
  2. Go to the Settings tab
  3. Select Manage Access
  4. Click Invite a Collaborator
  5. Type in the username, full name, or email of the person you want to invite
  6. Click the button add SamG-H to this repository (or whatever the invitee's username is)

An email will be sent to the user and they have 7 days to accept the invitation. After they have accepted they can clone a copy of the repo and start contributing to your awesome project!

A Push

It is time to move on to the commands that work with our remote repository, e.g. GitHub, now that we know the local basics of git. Pushing is what takes our commits and 'publishes' them to our remotely hosted repo on GitHub. After we have made a few commits we should push them using git push origin main replacing main with whatever branch you are working on (make sure you've added your remote repo correctly; I go over that in part 1 of this series). This push will save all of our commits giving our fellow coders access to the changes we have made.

And a Pull

Through pulling we can update our local machine's copy of the repo with the freshly updated (aka pushed) version now on GitHub. Pulling is equally important to pushing. As you can probably guess, pulling takes the most recent changes from the remote repo on GitHub and applies them to our local copy of the repo. Pulling is essential when collaborating with others because we want to be working with the latest code. To summarize- git pull before making any changes and git push once you would like to save your changes to the web!

Branches... Again

I cannot stress enough that in order to use git effectively, some may even say correctly, we need to utilize branches. This is even more important when working with others. It would be extremely frustrating to our fellow contributors if they were to pull any updates from the main production repo and find that the project is now broken. That is why we must create a new branch, add new features to the branch, fully develop and test our new features in the branch, and then and only then should we merge the changes into main. This way everyone will be working with the best version of the project at any given time. Never commit changes directly to main.

The End

I've loved learning more about git and GitHub, and I hope this series was informative! If you have any questions/comments feel free to reach out!

Top comments (0)