Intro-to-Git

Intro to Git Workshop: Home

Intro to Git: Description

This guide provides additional resources to supplement the hands-on Intro to Git Workshop offered at the UNC Libraries: learn how to use Git, one of the most popular version control systems in the world. You don’t have to be a developer to git started!

The last workshop was taught on Wednesday, October 3, 2018 at Davis Library Research Hub.

Prerequisites:

  1. Download and install the latest version of Git

  2. Create a free GitHub account

Slides:

Basic Git Commands Cheatsheet

Setting up Git

$ git config --global user.name "Mona Lisa"

Sets your username in Git; can be different than GitHub username

$ git config --global user.email "example@example.com"

Sets your email address in Git; should be same as GitHub email address so GitHub can associate your commits with your account

Creating Git Repositories

$ git init

Turns any folder into a Git repository

$ git clone https://github.com/username/repo-name.git

Copies an existing repository to your computer

$ git remote add origin https://github.com/username/repo-name.git

Links your local repository with your remote repository

Making Changes

$ git status

Returns status of changed files in your git repository

$ git add index.md

Adds changes made to a given file or set of files (index.md in this example) to your staging area

$ git commit -m "Add index.md"

Saves a snapshot of changes with a summary message

$ git push origin master

Syncs commits from your local repository up to your remote repository

$ git log

Returns list of local commits, or a history of saved snapshots

$ git pull origin master

Syncs commits from your remote repository down to your local repository

Bonus

$ git diff

View unstaged changes made to all files in your git repository

$ git remote add upstream https://github.com/original-owner/original-repo-name.git && git pull upstream master

Syncs your forked repository to the original repository. For more information, see GitHub’s Configuring a remote for a fork.

Other Resources

More Tutorials:

Tools:

Other Resources: