A couple of days ago I uploaded a video on YouTube that gives and introduction to Git and GitHub. In this video, you will learn the basics of Git (init, add, commit, branch) and you will learn how to collaborate on GitHub (pull requests and merging). You can watch the video here:

I also am providing a quick review of the git commands that were covered in this video below.

Creating Git Repositories:

$ git init 

Turns an existing directory into a git repo. (Creates the .git hidden folder)

$ git clone [URL]

Clones (downloads) a repo that already exists online. This includes all the files, branches, and commits

Working with Branches

$ git branch [branch-name]

Creates a new branch

$ git checkout [branch-name]

Switches to the specified branch and updates working directory

$ git merge [branch-name]

Merges the specified branch into the currently checked out branch.

$ git branch -d [branch-name]

Deletes specified branch (not in video)

Making and Viewing Changes

$ git add [file]

Snapshot the file in preparation for versioning (aka staging the file).

$ git commit -m "[Commit message]"

Records file snapshot permanently in the history.

$ git log

List version history for the current branch.

Git Ignore

Sometimes you will need to exclude files from being tracked with Git. This can be done by using a file named .gitignore

You can find helpful templates for different programming languages here: https://github.com/github/gitignore

Synchronize Changes to Remote Repositories

$ git fetch

Downloads all history from the remote-tracking branches.

$ git push

Uploads all local branch commits to the remote repository (e.g. GitHub/GitLabs/BitBucket).

$ git pull

Updates the current local working branch with all new commits for the corresponding remote branch on the remote repository.