Julio Morales is a second year PhD student in the Department of Astronomy at New Mexico State University, where he conducts research on the flow of plasma in the solar interior using the technique of time-distance helioseismology. This work is part of the COFFIES collaboration, whose goal is to successfully simulate the solar magnetic field cycle. In addition to his graduate research, Julio also co-leads NMSUs “Inclusive Astronomy”—a committee dedicated to rigorous discussion and solutions to a variety of issues pertaining to diversity, equity, and inclusion.
Picture the frustration: let’s say your research requires you to change or add a feature to a code. You might work for days or even weeks implementing it. By the end of your efforts, you realize the way you did things before is favorable to what you’ve produced. Or perhaps you’re interested in recreating a result you had with the old version for comparison sake. If you don’t use version control, you would be fresh out of luck in reverting back to your old code. Version control is a practice that allows one to conveniently manage these challenges. With Git and GitHub, we have the essential tools for version control, archiving, and collaborative coding.
In essence, Git serves as the bookkeeper of your code’s evolution, meticulously tracking every change. In tandem, GitHub is where your code and its iterations are stored. It’s a dynamic synergy: Git encapsulates your code’s evolution, while GitHub houses the code itself and the documentation of its evolution. Notably, GitHub is a remote repository, a digital sanctuary safeguarding your code from local vulnerabilities and mishaps.
Git
Git boasts a multitude of functionalities, but for our purposes, we will discuss the “clone,” “fetch,” “commit,” and “push” functions. “git clone,” duplicates a repository onto your local machine, a crucial step preceding any code alteration. “Git fetch” acts as a local refresh, ensuring your version mirrors the latest repository modifications. “git commit,” saves your local modifications. “Git push” takes the local modifications made by you and stored by “git commit” and stores them to the remote repository—GitHub.
GitHub
I use GitHub primarily for the purposes of backing up my projects remotely. However, GitHub does have a few other functionalities that I have found useful for my research. For example, it has the ability to display two versions of your code side-by-side while highlighting the differences from one version to the other. This is a game changer if you are hunting down any changes that you have made to your code, especially if such modifications have drastically altered the result.
GitHub is also an indispensable tool for collaborative projects. Say you have multiple people working on a set of codes. Each of you contributes something to the code, but how do you keep track of what changes were done by whom? GitHub (alongside Git) makes this information easily accessible. For any repository, you can see a list of all the “commits” that have been made to the project. Each commit will show the author name, date and time, as well as a short message associated with the commit . If you click on the commit itself, you will have access to the details of the changes made to the repository.
In my research, Git and GitHub join forces to create a dynamic diary of my code’s changes. While I am still in the process of refining my approach, I try to make weekly “commits” and “pushes” so as to keep a very detailed record of my projects. Traditionally, the Git commands are done through the terminal, a skill well worth mastering (see Atlassian, W3, and TutorialsPoint for tutorials). However, contemporary tools like Visual Studio Code (VS Code) integrate with Git and GitHub, enabling code management with intuitive button clicks. In the next installment of this series, we’ll delve into the world of VS Code, my favorite all-in-one code and text editor.