Collaborating on Github

Collaborating on GithubJosephine YaoBlockedUnblockFollowFollowingMar 14After using Git and Github consistently in the coding labs at Flatiron School, I thought I had a good grasp on how to use both of these tools well.

However, I received a massive wake up call when I started working on my first pairing project and realized that I only knew how to use these tools effectively when I was the only person making changes to the code.

Collaborating on Github was a whole other beast that I had not yet tamed.

Before we get into the collaboration process, I wanted to explain briefly what these tools are and why we even bother to use them.

First off, Git is a version control system that allows us to track modifications made to our code, document when and where the changes happened, and see who made the changes.

The branching system in Git allows multiple people to make changes to our code without the fear of breaking the existing functionality.

This is what basically allows for the git commands you use in your terminal.

Github is a company that offers a cloud-based repository hosting service for Git.

It is a remote way of saving our code from a local machine (for example, our computer) to a remote server (for example, Github) where it can be accessed by others.

When working on a team of multiple developers, this “hub” allows for easier collaboration and communication.

It also allows for errors and a way for us to go back to previous working code.

Not fully understanding how to work together on Github definitely slowed our progress during the project.

I became determined to learn more about this topic so that I could work more efficiently with others in the future.

After going down a rabbit hole of research, I discovered that many developers had slightly different processes on how they utilized Git and Github.

Because of this, I narrowed it down to a process that I felt would work best for me (and hopefully for you!) out of all the numerous methods I came across.

Now, let’s start collaborating!Fork the repository on GithubA repository is like a folder that contains all the coding files for your project.

When you are forking a repository, you are creating your own copy of the repository.

This allows you to make changes to the code without the fear of affecting the original project.

After navigating to the main repository page, fork the repository by clicking on the “Fork” button on the top right.

git clone github-repo-urlNow, you want to clone the repository to your local machine (your computer).

You can do this by clicking the green “Clone or download” button on the right.

I prefer grabbing the “SSH Key” as it is more secure, in my opinion, but I won’t go into details here as to why.

You can toggle between the HTTPS or SSH and copy the link provided.

After you navigate to the correct folder you want to work in on your terminal, type in “git clone” and add the link you just copied into your terminal.

After it is loaded, type in “cd” and the folder name to change into that directory.

git checkout -b MyBranchNameBefore you do any coding, you need to create your own branch.

This is a safe place in your local repository that’s separate from the master branch.

This is where you can work on your edits without altering anything in your master branch.

After creating your new branch, you can make a new file and start coding!git add .

Any modifications you have made to your code will need to be added to a staging area where it’s being prepared for a commit.

You may add specific files one by one but, in this instance, we are adding all our changes at once with the dot notation.

git commit -m “Your detailed but concise notes about your changes”A commit wraps up all your changes and saves them permanently into your local repository.

It’s a good habit to commit often and write detailed notes.

This helps you stay organized and have multiple checkpoints to go back to in case your code breaks.

git push origin MyBranchNameThis updates your remote repository of any commits you have made locally to your branch.

Create a pull request on GithubThe person who is head of the remote repository will get a notification that you have made changes, review your changes, and decide whether or not they want to merge your changes.

To do this, go to Github and navigate to your forked page of the main repository.

In the “Branch” menu on the left side, select the branch that contains all the commits you just made.

Courtesy of Github.

comOn the right of the “Branch” menu, click “New pull request.

”Courtesy of Github.

comUse the “base” branch drop-down menu to choose the branch you want to merge your changes into.

Then, use the “compare” branch drop-down menu to select the topic branch you made your changes in.

Courtesy of Github.

comGive your pull request a title and a detailed description of what changes you have made.

Courtesy of Github.

comThen, to create a pull request that’s ready to review, click “Create Pull Request” and you’re done!Courtesy of Github.

comNow, the person in charge of the main remote repository can click on the “Pull Requests” tab on Github, review the changes you’ve made, and decide whether or not they want to merge your changes.

If everything looks great, they can click “Merge pull request” and confirm the merge.

All the changes that you’ve made in your pull request is now merged with the main remote repository.

You’re done!You now know how to work together on Github!.Not too bad, right?.I highly encourage you to do additional research as there is so much more information on Git and Github than I covered here.

It’s also a very useful skill to have as a professional developer.

Have fun!.

. More details

Leave a Reply