Let’s Fork With GitHub

Khongkwan
Khongkwan
Feb 28 · 5 min read

Are you one of the people who work with tons of files?

It is undeniable that collecting many versions of files is annoying somehow. Unpredictable things might occur during this time. The original file and the latest version that you just fixed could easily be swapped, in case that you do not carefully pay attention to the file names that you just saved, or you might found that you deleted the recent fixed file instead of the earlier version. For worst, you may have no idea that what was the file that was recently fixed and which part of it that was fixed.

To avoid these annoying issues, using GitHub sounds like a good idea when it comes to version control. This platform could help you deal with many versions of files that you are working on and store them regularly. This is also perfect for people who work as a group since you can easily share all your works with others and get what was on others to your own. The most interesting thing is that this shows every change that you do on your file. You can easily trackback or compare each version of the files that you created with a single click.

This tutorial will basically guide you on how you use GitHub with a little application on RStudio.

Fork a Git Repository

Now, let’s start with how to get files. In case that you found some interesting files in another’s repository, you can easily get them straight into your repository by using Fork.

Go to the repository that you want to fork

To fork a repository, go to a repository that you want to copy for your own and then click Fork.

Fork button appeared on the top-right of the Git repository

Now, you can see the repository that you just forked is already in your GitHub.

The forked repository appeared in your GitHub

Create a Branch

After you got that repository in your account, you may want to edit some of them without permanently changing them into the fixed version. Here, you can create a branch that helps you create a change without affecting the original files.

You can go to your forked repository, which is the main branch, and then create the other branch to make safe editing.

The main branch showed on your forked repository

You can create a new branch by giving it a name and then click Create branch.

Type your branch name and click Create branch

After the branch was created, you will see the gained number of branches on your repository.

A new branch was created

Now, you can edit all the files in your new branch without changing the original files in the main branch.

Adding a New File

The other way to get files into your repository is to add some files into your repository, you can pick the finished one and share them to your GitHub or just create a new one on your repository now.

Add file options

If you click Create new file, you will find an empty space for your new work.

You can start doing your work here

After you finished your work, you can click Commit new file to save this into your repository.

You can add any descriptions and then click Commit new file

If you want to add the files directly, you can drag your file here or choose them manually.

Upload file and click Commit changes

After the files were uploaded, you can again add the comment and commit them to your repository.

Cloning Repository

You can also get a copy of other’s repositories into your computer by using Clone.

First, go to the repository that you want to get, click Code and copy the link.

Click the Code button and copy the repository link

In this case, I will clone the repository to my RStudio. So, I put the link into my RStudio Git setting.

Put the link to create R project from that repository

Commit the Changes and Push Local Files to Remote Repository

After I have done working on my cloned R project, I will commit the files saved on my computer and push them into my GitHub by using Commit and Push.

I selected files that I want to commit, added some messages, and then clicked commit. After I committed, I clicked push to send the file to my selected repository.

Committing and pushing files

Then, I got back to my GitHub and found that the files I just pushed are there.

Pushed files showed

Create a Pull Request

Now, I can compare the original and the edited one that I just added by clicking Compare & pull request.

After I finished checking the differences, I created a pull request to merge the files of this working branch into the original, main branch.

Choose the repositories and branches that you want to merge and then click Create pull request

Finally, the edited files that I want to add appeared on my main branch.

And that is how I deal with numerous versions of files! I hope this could help you work on files more efficiently. If you have any questions or want to share something, kindly feel free to let me know below.

So, next time, don’t fork with tons of files, just fork them on GitHub!

Star Gazers

“If you want to master something, teach it.”

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store