Skip to content
Shreyas edited this page Feb 5, 2014 · 1 revision

Notes for Setting up Git/Github

Link to my presentation on Git/Github on SpeakerDeck

Please find below instructions for the following tasks

  1. Install & set up Git
  2. Configure Github and access the course repository

Install & set up git

You can install git using the binaries available for download at git-scm.com/downloads

Install Git

Next, configure your Git with necessary/reasonable defaults, by running it on your terminal/command prompt/power shell

$ git config --global user.name <YOUR NAME>
$ git config --global user.email <YOUR EMAIL ADDRESS>

Also, it might be helpful if you ran this:

$ git config --global push.default current

which ensures that when you push it takes the current branch by default.

Once installed proceed to set up your Github

Configure Github

  1. Request an educational account from github : github.com/edu
  2. Set up your SSH keys for your account
    1. Go to Account Settings > SSH Keys github.com/settings/ssh to view/create SSH keys, for your machine.
      1. To create your SSH key, follow the Generating SSH Key instructions
  3. Clone Course Repository on your workspace machine (it is up to you to use ISchool server machine or your local machine)
    1. Go to Course Repository page, and copy the repository url. Make sure you are copying the SSH version of the url.

      1. It should be : git@github.com:jretz/datamining290.git
    2. Create your own Github repository for doing the course work.

      • Click on New Repository button and fill in the details, as shown in the figure
      • Make your repository Private
      • Make sure you UNCHECK the Initialize the repository with a README file, and also leave the Ignore Files and License File checkboxes as NONE (as shown in the figure)
      • Create your repository
      • Copy your Github repository URL. Lets call it <YOUR_GH_REPO_URL>
      • Add Jimmy (@jretz) and Me (@seekshreyas) as collaborators in your private repository, so we can see your files.
        • You can add collaborators at: Repo Settings > Collaborators
        • "Add Collaborators"
    3. Open your terminal (on Mac/Linux) or powershell (on Windows), and navigate to the desired folder/directory where you would like to download and set up the course repository. Then,

      • Clone the repository on your machine
        • $ git clone git@github.com:jretz/datamining290.git <FOLDERNAME (optional)>
      • Navigate to the repository folder
        • $ cd <FOLDERNAME>
      • Update the remotes of the the repository.
        • Check the current remotes first

          • $ git remote -v
          • It should look something like this:
              jimmy   git@github.com:jretz/datamining290.git (fetch)
              jimmy   git@github.com:jretz/datamining290.git (push)
              
        • Modify the remotes:

            $ git remote rename origin jimmy
            $ git remote add origin (YOUR_GH_REPO_URL)
            
        • Check the remotes again, with $ git remote -v command. It should show something like this:

          jimmy   git@github.com:jretz/datamining290.git (fetch)
          jimmy   git@github.com:jretz/datamining290.git (push)
          origin  git@github.com:seekshreyas/datamining290T.git (fetch)
          origin  git@github.com:seekshreyas/datamining290T.git (push)
          

Thats it you have successfully set up the course repository on your machine.

Further Git Resources

Following links are useful as Git resources

For advanced git users

Some sensible configurations, shortcuts and aliases. I leave to the individuals to figure out themselves on how to implement them.

Configurations

.gitconfig file settings

[alias]

    # View the SHA, description, and history graph of the latest 20 commits
    l = log --pretty=oneline -n 20 --graph

    # View the current working tree status using the short format
    s = status -s

    # Show the diff between the latest commit and the current state
    d = !"git diff-index --quiet HEAD -- || clear; git diff --patch-with-stat"

    # Clone a repository including all submodules
    c = clone --recursive

[color]
    # Use colors in Git commands that are capable of colored output when outputting to the terminal
    ui = auto


[merge]
    # Include summaries of merged commits in newly created merge commit messages
    log = true

Clone this wiki locally