Using GitHub
When I started out programming, I had no idea what GitHub was - I just knew it was a popular tool in the programming world.Now, it’s a tool I use all the time: it lets you store and organise your programming projects, find, download and contribute to other open source work, revert to old versions of your code, and track and manage changes when you’re working in a group.
## Set Up GitHub You can quickly make an account and start using GitHub by downloading GitHub Desktop. This is a friendly tool that provides version control for your local files, and allows you to store them in the cloud on GitHub.com.
To start, go to GitHub Desktop -> Settings -> Git and set your email to the generated email ending in @users.noreply.github.com. Unless your email is already public, using this email prevents bad actors from seeing your real email. If you’re setting up a GitHub account in a workplace, they might ask that you use your work email instead.
Make an SSH Key
Advanced {: .label .label-yellow }
Once you’ve made an account, it is helpful to make an SSH key. Because it’s technically possible for anyone to make a submission in your name, using a key verifies all contributions as yours, protecting your work from bad actors, and preventing impersonation if you contribute to public repositories.
If you are getting really confused by this, that’s okay. You can remove an SSH key, start over, find old ones, and add and remove them to your account at any time. You don’t need one, especially when you’re just starting out - so it’s okay to come back to it when you feel more confident.
GitHub’s tutorial on key creation is the most up to date way to learn this. Make sure when you fill in your email, you use your new @users.noreply.github.com email.
Create an SSH Key with a password Make sure you follow the next instructions to add your SSH Key to the security agent. This will remember the password on your behalf - and if you’re on an Apple Device, it can save to iCloud Keychain, saving the key in the background across all your devices.
Create an SSH Key with a security key
When you’re ready to add the SSH Key to your account, visit https://github.com/settings/keys. If you’re at all confused, you can get help here.
Store and Organise Personal Programming Projects
Creating a New Project for the First time
GitHub stores each project in a ‘repository’, or ‘repo’ for short.
If you’re ready to start a new programming project, the fastest way to do so is to open GitHub Desktop and clicking Current Repository in the top left. Click Add, then Create new repository. Write a short name for your project.
It’s helpful to set a Git Ignore. By default, GitHub tracks all changed you make within a repo - but that might mean hidden files that your code editor and file manager get caught. These files do not help your code run and could update very quickly, so they need to go in your Git Ignore.
From the dropdown, pick the coding environment you are using: VisualStudio, Unreal Engine, Unity, Wordpress. If that isn’t applicable, pick the language you are programming in.
You do not need to set a licence, especially if it is a private project.
Click create. Congratulations, you made a repo! Go to your code editor, and click Open Repository to get started.
Migrating Your Old Projects
To add your old projects to GitHub, create a repo for each project then drag and drop your old files into the repo.
### Only use current projects Now you’ve moved old projects onto GitHub, you can take them off your computer. Within GitHub desktop, right click a repo you are no longer using and click Remove.
Find and Download Open Source Code
Have you ever found yourself sent to a Github repository, very confused as to how it all runs? Now, it’s really easy to get started!
Find a public project you want to make a copy of on GitHub.com. Click the neon green Code button, and you’ll find it’s now very easy to use. You can either Open in GitHub desktop, or amazingly open in your programming environment instantly. Try clicking “Open in Visual Studio” or equivalent, and watch as it opens on your computer!
Bear in mind that these repos are often just files. You might need to install a programming language to your computer so that it will run - for example, installing Python to run .py files.
Make Changes to Your Work, Open Source Code and Group Work
GitHub makes it possible for amazing advanced collaboration: for example, having your entire team working on a big codebase, each editing different areas. This is done using Commits, Clones & Forks, Pull Requests and Branches.
What Are Commits?
Whenever you make a change to your code/project, the changes are recorded by GitHub. You can see them appear in GitHub desktop while you work, and you can also see it in most programming environments.
Commits are points where you save your changes to a point in GitHub: for example, after you’ve created a brand new screen inside your app. You’ll make commits fairly regularly, but not as often as you save the files. They should be distinct points with clear progress, so if you need to revert to an early working version of your code, it will work and have clear progress.
Inside GitHub Desktop, write a little title and description in the bottom left, and press Commit to Main. There will be tools available inside your programming environment too - for example, Git in VSCode, in Visual Studio, and even (awkwardly) in XCode.
You might see it shown as Git or Version Control within your programming environment - GitHub is a web interface and host for files, but it runs on Git: an open source file management too.
Keep reading - as you need to understand Clones and the fetch and push tools.
What Are Clones?
When you made a local copy of the work you had in GitHub, that was a clone. This means that when you make commits, you have to Push them to the GitHub servers after - in GitHub desktop, it is the Push to Origin button in the top right, and in your programming environment it might look like a refresh button or an upload arrow.
What Are Forks, Branches?
Lots of people can clone your project at the same time. If they want to edit it substantially, they can use Forks instead - this is a Clone, but on the server side. This lets you make your own edits in a totally different copy, ready to save in later.
Branches