7 Putting codes on Github

Key terms/commands:

  • git push: upload your commits to a remote repository (like GitHub!)

7.1 Push an existing repository from your local computer

Go back to the local directory, workdir that we made in previous sections.

cd ~/workdir

Add the github repo you just made as a remote repository that you want to push your data to.

  • Replace your_username with your github username
git remote add origin https://github.com/your_username/workdir.git

Check what is listed as your remote repository now.

git remote -v
## origin   https://github.com/your_username/workdir.git (fetch)
## origin   https://github.com/your_username/workdir.git (push)

Push your local repository to your Github

git push –u origin master
## Counting objects: 3, done.
## Writing objects: 100% (3/3), 277 bytes | 277.00 KiB/s, done.
## Total 3 (delta 0), reused 0 (delta 0)
## To github.com:your_username/tmp.git
##   e06fb6f..d4a8d31  master -> master

BONUS - SSH keys

Here is a link to help you setup using SSH keys for authentication with Github https://help.github.com/en/enterprise/2.15/user/articles/adding-a-new-ssh-key-to-your-github-account

Your code is now available on Github!