Tutorial - How to use github.com for your projects.

Date: 2015-07-02

While at my last job it became useful to use some type of source code repository. The previous team used github we did the same. When I broke off, it became necessary to learn how to use github.com. The process always takes at least three (3) phases. Here they are.

NOTE: Setting up SSH with the github.com account allows the local code repository to be copied to the github.com account. This allows the github account to be your backup. If you don't setup ssh, you'll have to use your password everytime.

If you need an introduction into github.com, here is one
Introduction to GitHub

Phase #1: Create the project online

  1. Get a github.com account
  2. Login to github.com
  3. Setup SSH access
  4. Once you are logged in, there are three tabs on the page: Contributions, Repositories, and Activities. Click on Repositories
    Three Tabs
  5. One the right side is a greenish button, labeled New. Click it.
  6. The page will flip to form.
  7. Decide on a project name.
    Form Filled
  8. Type that project name in the box labeled Repository name
  9. Add some type of description (it will be needed).
  10. Click the checkbox that says Initialize this repository with a README. THIS IS IMPORTANT.
  11. At the bottom of the window, click the button Create Repository
  12. The page changes to the Initial Project
  13. On the bottom right is a small form, click the SSH hyperlink
    Initial Project
  14. The label and the stuff in that (small) form changes.
  15. Click the icon, that looks like a clipboard. That copies that URL to your clipboard.


That stuff in your clipboard, can be used immediately on the command line, if you wish.

Phase #2: Clone the project, Add files

  1. At the command line give the command git clone [email protected]:jessemonroy650/projectname.git
  2. The output should look something like this.
    [email protected]:~/PUBLIC3$ git clone [email protected]:jessemonroy650/projectname.git Cloning into 'projectname'... The authenticity of host 'github.com (' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Failed to add the host to the list of known hosts (/home/jessem/.ssh/known_hosts). remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. Checking connectivity... done.
  3. cd projectname/
  4. If you get a listing (ls -l), you'll only see one file. -rw-rw-r-- 1 jessem jessem 36 Jul 2 02:42 README.md
  5. create or copy files into this directory
  6. for each file you want in the repository, at the command line type git add filename
  7. create a file named .gitignore
  8. for each file you do NOT want in the repository, put that filename in the file .gitignore. One filename per line.

Phase #3: Push the project into github

Since I do this all the time I have a script (batch file) in the directory that I use. That filename is include in .gitignore.

Here are the two (2) essential remaining steps.

  1. git commit --all --message "${COMMENT}"
    This commits the all changes to the local respository. There is an option to only commit certain files. There is an option to force no comments/message.
  2. git push
    this copies the local repository *changes* to github.com

Lastly, if you get a network failure and you cannot copy to github.com, wait some time until can copy those files to github.com, and issue the git push at the command line.

That's It

Setting up SSH

  1. Click top right icon
  2. Click Setting from the drop down menu
  3. The page changes
  4. On left, click SSH Keys
  5. The right window pane changes
  6. Click, Add SSH Key
  7. Form appears just below
  8. Fill in the Title
  9. Fill in the Key with your public SSH Key

Alternative to SSH

  1. Edit .git/config
  2. https://yourLoginName@github.com/yourLoginName/yourProjectName
  3. You'll still need to use your password

Content Network Distribution by: