Skip to content

Git and Github

Aron Trauring edited this page Sep 10, 2017 · 5 revisions

How to Configure and Work with Git and Github

How to Set Up Dev Tools to Work With Git and Github

Step-by-step guide

One Time SSH Set Up

How Many SSH Keys

You need to add an ssh key to Github for use in validation. If you work on various machines, one option is to have the same key on all of them. In that case, you need to copy the private and public versions of that key to all other machines you want to work with. The downside of this approach is that you’ll need to do this copy again to all machines, if any one of those machines are lost or stolen. A paranoid sysadmin would probably delete all of them anyway, even if you use different keys on different machines, not trusting you kept straight which key belongs to which machine. In any case, you should create a separate key for Github only, because if this key is compromised you don’t want to have to replace it everywhere else you might use it.

  1. On your primary dev machine (likely a Mac) generate an ssh key. The sample below generates a key named id_rsa. If you already have one with that name, add the optional flag and output-filename: ssh-keygen -b 2048 [-f .ssh/
  2. Copy the public and private version of that key to all other dev machines. If you do copy and paste in Windows, do it in a VS Code window and save from there. Doing it in a terminal will cause funky problems and the key won’t be recognized by ssh.
  3. Cat the .pub public key file and copy the text.
  4. Go to the Github user settings and select SSH and GPG keys. Click on New SSH Key and paste in the public key you copied above. Then save.
  5. In the Git Bash shell run the command ssh -vT git@github.com. This is necessary so so that you can ssh to Github properly moving forward. Say yes to add Github to your known hosts.

Post Installation Configuration

  1. After installing the git client on your machine, run the following commands to configure git:
    git config --global user.email "<company github email>"
    git config --global user.name "<github-username>"
    git config -l # check git configuration is set up properly with email and username
    

Installing GitHub Desktop

  1. Download and install Github Desktop from here.
  2. Log in with your user credentials.
  3. On Windows, set the console to be ConsoleZ and adjust its settings according to the instructions here.

Setting Up Git for Visual Studio Code

  1. First install Visual Studio Code and all its extensions as described here. Go to Configure Settings and find the "git.path" setting. Add the following definition:
    {
        "git.path": "C:\\Program Files\\Git\\bin" # on Windows
        "git.path": "/usr/local/bin/git" # on Mac OS X -- this is the brew version
    }
    
  2. For the first installation of VS Code, go to  Github & choose Settings. Then choose Personal Access Tokens. Create a new token for VS Code and give it all permissions and click Generate Token. Make sure to copy the token and store it in 1Password. If you have already created it, copy it from 1Password.
  3. In VS Code, install the Visual Studio Github Support extension. Then from the menu choose View → Command Palette and then choose the command Github: Set Personal Access Token. Paste in the token you copied in previous step.
  4. You will also need this token to set up the VS Sync Settings extension.

Setting Up Github for Visual Studio

** Setting up Github for **

Related Links

Link Description
Mastering Markdown Mastering Markdown Guide
Git Credential Manager for Windows Git Credential Manager for Windows Github and Doco
Visual Studio Code Github Support Visual Studio Code Github Support Description in VS Marketplace
RStudio and Github Rstudio and Github Guide