Git, GitHub, Version Control
NC State gives you access to GitHub Enterprise: https://github.ncsu.edu/. This is different from https://github.com/, which you can use for your personal GitHub needs (but NOT what we use in this class). Most NC State classes where you use GitHub will use the Enterprise version. Some classes may have you use the general GitHub page and set up an account there. What is GitHub for?
Lecture Video: Git and GitHub →
Imagine you’re collaborating with a faculty member on a research paper. If you take turns working on a whole paper, each of you will spend a lot of time waiting for the other to finish. But if you work on your own copies and email changes back and forth, things will inevitably get lost, overwritten, or duplicated.
This is where version control comes in. Version control (or revision control, or source control) is all about managing multiple versions of documents, programs, web sites, etc.
It’s essential for managing multiple versions of documents, programs, and websites. It provides a “time machine” for your work, allowing you to track changes over time, recall previous versions, and see exactly who made what modifications when.1:
Nothing that is committed to version control is ever lost, unless you work really, really hard at losing it. Since all old versions of files are saved, it’s always possible to go back in time to see exactly who wrote what on a particular day, or what version of a program was used to generate a particular set of results. When several people collaborate in the same project, it’s possible to accidentally overlook or overwrite someone’s changes. The version control system automatically notifies users whenever there’s a conflict between one person’s work and another’s.
Teams are not the only ones to benefit from version control: lone researchers can benefit immensely. Keeping a record of what was changed, when, and why is extremely useful for all researchers if they ever need to come back to the project later on (e.g., a year later, when memory has faded).
Some well-known version control systems are CVS, Subversion, Mercurial, and Git. We’ll use Git and GitHub!
We’ll only use the features you need to complete your labs in this course. GitHub and version control can do much more, but that’s outside the scope of this course. In this chapter, we’ll learn how to:
- Create your own GitHub repository (repo)
- Build a simple webpage and track changes to it
- Publish that webpage using GitHub Pages
Learning Outcomes
Use campus computing services
Create and design basic web pages
Chapter Learning Outcomes
- Explain the purpose and benefits of version control systems.
- Create a GitHub account and set up a repository.
- Create a GitHub Pages site from a repository.
- Explain the folder structure and requirements for GitHub Pages.
- Deploy a static website using GitHub Pages.
What happens to my GitHub @ NCSU data/account when I graduate?
Your GitHub account is tied to your Unity ID, so you’ll lose access when you leave NC State. To keep your work, follow GitHub’s guide to migrate repositories to a personal account.
If you’re collaborating with a faculty member or team, transfer ownership before you leave. The recommended method is to create a GitHub organization named ENGR-CSC-XXXXXX
, where XXXXXX
reflects your project. Make the faculty member the owner so access is preserved long-term.
Organizations ensure long-term access and control even when individuals leave the university.
For all other personal repositories, it is strongly recommended you archive those before your access to NC State GitHub is disabled. For more information about GiHub best practices, policies, and FAQs please visit:
- https://docs.github.ncsu.edu/github-best-practices/
- https://docs.github.ncsu.edu/policies/
- https://docs.github.ncsu.edu/faq/ [under review]
- How to Create a GitHub Organization
Exercises
- Eventually, you may like to showcase your skills to an employer. To keep track over time, you may like to keep a “lab notebook” or “portfolio” showing your personal projects. Set up a Jekyll or Hugo website, and write a blog post or similar every once in awhile. Since this is a personal page, you can name it whatever you like. Consider using a setup like this link (which is on GitHub Enterprise for NC State), or look online to learn how to build a page, e.g., using the introduction to Jekyll.
- You’ll set up the webpage for our class on GitHub Account Preparation, and later learn some basic HTML. You can also learn markdown so that you can format research notes or blog posts.
- A web page should make it easy to find the following information:
- Your name and how to contact you (you can put this in the footer).
- A description of what the web page is for.
Comparing GitHub, NFS, and FileZilla
Tool | Type | Primary Purpose | Common Use Cases | Advantages | Limitations |
GitHub | Version Control & Collaboration | Managing and tracking code versions | Tracking changes, team collaboration, code review | Version tracking, cloud-based, excellent for collaboration | Primarily for code, not large binaries, requires understanding of Git concepts |
NFS | Network-Based File Storage | Allowing file sharing across computers | Accessing shared lab resources, shared organizational directories | Fast access over LAN, reduces file duplication, seamless local drive-like access | Requires network access, slower over high-latency networks, limited to local/VPN |
FileZilla | File Transfer Client | Transferring files to/from servers | Uploading to web servers, downloading course materials, moving files | Easy-to-use GUI, fast/reliable transfers (FTP, SFTP), cross-platform, multi-protocol support | Requires server credentials, limited to file transfer (no version control/shared access) |
- See Software Carpentry for extended lessons (also major source for our information!): https://swcarpentry.github.io/git-novice/ Or see to https://carpentries.org/) via a CC license (link to the license) ↩︎