Git GitHub User Guide - Scrum-Lords/User-Guides GitHub Wiki

Git/GitHub User Guide by Rob Shea

What is Git/GitHub? Git is an open source distributed version control system that facilitates GitHub activities. GitHub is a web-page where you can publish your Git repositories and work with other people.

###Configuring Commands

$ git config --global user.name “[name]” – sets the name you want attached to your commits.

$ git config --global user.email “[email]” – sets the email you want attached to your commits.

$ git config --global color.ui auto – enables helpful colorization of command line output.

###Creating Repositories

$ git init [project-name] – Creates a new local repository with the specified name.

$ git clone [url] – Downloads a project and its entire version history.

###Making Changes

$ git status - list all new or modified files to be committed.

$ git diff - shows file differences not yet staged.

$ git add [file] - snapshots the file in preparation for versioning.

$ git diff --staged - shows file differences between staging and the last file version.

$ git reset [file] - unstages the file, but preserves its contents.

$ git commit -m "[descriptive message]" - records file snapshots permanently in version history.

###Group Changes

$ git branch - Lists all local branches in the current repository.

$ git branch [branch-name] - creates a new branch.

###Refactor Filenames

$ git rm [file] - deletes the file from the working directory and stages the deletion.

$ git rm - cached [file] - removes the file from version control but preserves the file locally.

$ git mv [file-original] [file-renamed] - changes the file name and prepares it for commit.

###Save Fragments

$ git stash - temporarily stores all modified tracked files.

$ git stash pop - restores the most recently stashed files.

$ git stash list - lists all stashed changesets.

$ git stash drop - discards the most recently stashed changeset.

###Review History

$ git log - lists version history for the current branch.

$ git log --follow [file] - lists version history for a file, including renames.

$ git diff [first-branch]...[second-branch] - shows content differences between two branches.

$ git show [commit] - outputs metadata and content changes of the specified commit.

###Redo Commits

$ git reset [commit] - undoes all commits after [commit], preserving changes locally.

$ git reset --hard [commit] - discards all history and changes back to the specified commit.

###Synchronize changes

$ git fetch - [bookmark]** - downloads all history from the repository bookmark.

$ git merge [bookmark]/[branch] - combines bookmark's branch into current local branch.

$ git push[alias] [branch] - uploads all local branch commits to GitHub.

$ git pull - downloads bookmark history and incorporates changes.

###Example Image Here is an example of one of our group members (Rob Shea) using some basic git commands (push/commit) while working on his portfolio. Example Image