Versioning Code With Git
Git is a tool for versioning code. A git repository is a folder of files where changes made over time have been recorded. You might have encountered version control using software like Dropbox, Google Drive or Fusion360, all of which automatically versionkeep records of changes to files. Git is designed specifically for versioning code,code, itand doesis notused needubiquitously in a networkprofessional connectionsoftware todevelopment work, and also comes with a range of advanced tools that allow multiple people to collaborate on the same files.context. If you've ever broken some code and wished you could go back to an earlier version, this is a classic use-case for git.
Git is distinct from Github, which is a website used to host and share git repositories, though the two are very often used together. Github is an extremely useful complement to git, which not only provides a smooth way to share and collaborate on code, but also allows free (!) hosting of websites via a service called Github Pages.
There are lots of great tutorials for using all of these tools, so this page is mostly a list of useful links with a broad description of principles.
Setting up Git on Your Computer
The first step is to download git -- there are versions for Windows, Mac and Linux. When interacting with git on a Mac or Linux computer, you will want to use the Terminal (sometimes called Shell, or Command Line on Linux). If you have a Windows computer, you will want to use Git Bash (the shell that you get when you download git) rather than Command Prompt for the tutorials linked below. (the reason for this is that Git Bash is a Unix-type shell, not a Windows shell -- the two have different sets of commands).
Installing git on Windows will get you to go through mulitple setup stages: it's fine to just go with the default for each, though it's a good idea to set your default branch to 'main' when prompted.
It is possible to use git via a GUI (a graphical interface that you click on, as opposed to a Terminal interface), Github Desktop is probably the best of these. I'd recommend trying to use the terminal version if you can, though, as through doing so you get a much better understanding of the process.
Making a Git Repository
A 'git repository' is a folder full of versioned files that lives on your computer (which you can choose to link to a Github repository, or not!). Key to understanding git is understanding how files are stored
The above tutorials contain longer discussions of how to use the commands listed here, but I've condensed them into a short 'cheat sheet' for reference.
Core git commands:
1. git init -- make this folder into a git repository
2. git status -- what's up with my repository
3. git add . -- tells git you'd like to save *all* the changes you made
4. git commit -m "some message" -- versions files with a message
5. git push -- pushes commits to github if it's been set up
Core unix commands:
These are really gonna make a difference to your life if you know how to use them. It's possible to do these things in the file browser too, but knowing how to do these in terminal will save you a lot of time!
1. cd -- 'change directory' -- change the folder you're in
2. touch -- ¯\_ (ツ)_/¯ -- make a new file
3. ls -- 'list' -- list the files in a folder
4. mkdir -- 'make directory' -- make a new folder
5. clear -- clears the terminal output
6. pwd -- 'print working directory' -- prints the path to the folder you're currently in
Linking a Git Repository to a Github Repository
For this you will need to make a Github account
SSH key
The CCI Github Server
Making a website with Github Pages
If nothing else, Github provides a clean and effective way of setting up a website for free. Git also integrates with services like Netlify and Vercel, which allow for more advanced sites to be set up, but for a basic HTML or Jekyll site Pages is totally great.
- adding custom domain to Github Pages