In this tutorial, we will walk you through creating your own GitHub account, creating a private repository (so your code won't be publicly visible on the web), and cloning and pushing content to your private, online repository.
Note: You should never create a public repository for work that you are doing for a class.
As students, you receive free access to GitHub Pro while you are a student. To set up your account:
- Make a normal GitHub account using your
@uga.eduemail address here: https://github.com/join - Go to the Education Pack "join page" on GitHub: https://education.github.com/pack/join
- Click on "Get your Pack".
- Click on “Get Student Benefits” and Sign In with your Account, if needed.
- Fill out the form and submit for review
- Wait on email confirmation from GitHub. Hopefully, this will take less than a day.
Before you can push and pull to private repositories hosted on GitHub from your Odin account, you will need to create an SSH public/private key pair on Odin. This will allow you to give a public key to GitHub (think of it as a padlock) that GitHub can use to authenticate your requests in addition to or in lieu of your GitHub username and password. It's sufficient to think of this key-based authentication process as you unlocking the public key (i.e., the padlock) using your private key -- the Git program will do this with GitHub so long as the key pair is setup correctly.
-
Login to Odin.
-
Before you type the following command, please note that it will prompt you to answer questions.
- Do NOT change any values when prompted -- simply press return until the
ssh-keygencommand is finished executing. - When asked for a password, simply press return -- do not enter a password.
With all of that in mind, please execute the command below, replacing
your_email@uga.eduwith your@uga.eduemail address.$ ssh-keygen -t ed25519 -C "your_email@uga.edu"This creates a public / private key pair in the default location:
~/.ssh/. - Do NOT change any values when prompted -- simply press return until the
-
View your public key using
catand copy its output to your clipboard (usually by selecting the text in your terminal, then right clicking on the selection and clicking "Copy"):$ cat ~/.ssh/id_ed25519.pub -
Login to GitHub.
-
In the upper-right corner of any page, click your profile photo, then click Settings.
-
In the user settings sidebar, click SSH and GPG keys.
-
Click New SSH key or Add SSH key.
-
In the "Title" field, add a descriptive label for the new key. For example, if you're adding a key for your Odin account, then you might call this key "Odin".
-
Paste your key into the "Key" field. This should be the copied output from your prior call to
cat. -
Click Add SSH key.
-
If prompted, confirm your GitHub password.
-
On Odin, verify that your key pair is setup correctly by trying to SSH to
git@github.com(do not change the username):$ ssh git@github.com-
You may see something like the following:
The authenticity of host 'github.com (www.xxx.yyy.zzz)' can't be established. RSA key fingerprint is ... ... Are you sure you want to continue connecting (yes/no)?Type
yes, then press return. It may emit the following warning, but that's okay and to be expected:Warning: Permanently added 'bitbucket.org,...` -
If you see something similar to the following, then you should be okay to proceed:
PTY allocation request failed on channel 0 Hi <YourGitHubUsername>! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. -
If you see the following, then something went wrong:
Permission denied (publickey).
-
- Login to GitHub
- Click on "New" under the repositories section on the left-hand side of the page.
- You should see a screen similar to the image below. Type
cs1302-testRepoas the name of your repository, click the "private" radio button and then press the "Create Repository" button.
-
Once you've clicked the "Create Repository" button, your repository is created but still needs to be setup. GitHub should be showing a website which gives you a few options on how to setup your repository. Instead of following those instructions directly, we will setup our repository from Odin using the following commands:
-
Clone your repository on Odin using
git clone git@github.com:username/cs1302-testRepo.gitreplacingusernamewith your GitHub username. You may get a message saying you've cloned an empty repository. That's okay! You should now have a folder calledcs1302-testRepo. -
Change into the
cs1302-testRepodirectory. -
Check the status of your local repository using
git status.
NOTE: Take note of the branch name displayed in the output (i.e., the
<name>inOn branch <name>).
-
If the current branch name is not
main, then rename it tomainusinggit branch -M main.
NOTE: The
-Moption moves/renames a branch and the corresponding reflog. Historically,masteris the name that many versions ofgituse for the first branch that is automatically created viagit init. In 2020, the Git development community and its partners reflected on the fact that the word "master" has negative connotations for many groups of people and started encouraging the use of more inclusive branch names such asmain. You can read more about it here and here. Future versions ofgitmay adopt
-
Create an initial
READMEfile usingecho "# cs1302-testRepo" >> README.md. -
Add your
READMEfile to the repository usinggit add README.md. -
Commit your changes using
git commit -am "first commit". -
Push your changes to GitHub using
git push -u origin main
NOTE: The
-uor--set-upstreamoption sets the upstream information for your the current branch in your local instance of the repository. Ifgit push -u origin mainis successful, then argument-lessgit pull,git push, and other commands will be enabled for your local repository. That is, if a remote repository name and branch (or refspec) are expected but not provided, then many commands will simply default to the upstream information. You are encouraged to readgit help pushfor more information about upstreams and refspecs. The next time you need to push or pull toorigin main, you can simply use argument-lessgit pushorgit pull, respectively.
ERROR: If the
pushfails and you seeerror: src refspec main does not match anyand/orerror: failed to push some refs to ..., then it is very likely that your local repository is empty (i.e., its commit log is empty) -- you can verify this usinggit log.- If you're following this turorial for the first time and
your commit log is empty, then that means you skipped one or more of
the previous three steps. Attempt to repeat the steps that you're missing
before executing
git push -u origin mainagain. - If you're replicating the steps in this tutorial for a new repository,
then simply stage and commit some files to the respository
before executing
git push -u origin mainagain.
- If you're following this turorial for the first time and
your commit log is empty, then that means you skipped one or more of
the previous three steps. Attempt to repeat the steps that you're missing
before executing
-
Refresh your GitHub page to see the changes to the repository. Your repository should look similar to the below image. Note the number of commits (1 so far) to this repository, the latest commit time, and the contents of the
READMEfile are all shown onGitHub.
-
- Now that your repository is set up, let's get some more practice. On Odin, do the following:
- Open your
README.mdfile. - Type a few additional sentences.
- Commit your changes locally.
- Push your changes to GitHub.
- Refresh the GitHub page to make sure your changes have been added to the online repository.
- Delete the entire
cs1302-testRepofolder from Odin. - Wait. Delete my entire project from Odin?!? Yep, do it.
- Execute the
git clonecommand from above. And it's back! - Note: you could clone from any machine that has
gitinstalled. You've all been cloning cs1302 GitHub repositories all semester.
- Open your
Congratulations on becoming a member of GitHub!
Copyright © Michael E. Cotterell, Brad Barnes, and the University of Georgia. This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License to students and the public. The content and opinions expressed on this Web page do not necessarily reflect the views of nor are they endorsed by the University of Georgia or the University System of Georgia.

