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.
To fork a repository, go to a repository that you want to copy for your own and then click Fork.
Now, you can see the repository that you just forked is already 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.
You can create a new branch by giving it a name and then click Create branch.
After the branch was created, you will see the gained number of branches on your repository.
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.
If you click Create new file, you will find an empty space for your new work.
After you finished your work, you can click Commit new file to save this into your repository.
If you want to add the files directly, you can drag your file here or choose them manually.
After the files were uploaded, you can again add the comment and commit them to your 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.
In this case, I will clone the repository to my RStudio. So, I put the link into my RStudio Git setting.
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.
Then, I got back to my GitHub and found that the files I just pushed are there.
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.
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!