Skip to content

Instantly share code, notes, and snippets.

@tathamoddie
Last active December 27, 2015 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tathamoddie/7313428 to your computer and use it in GitHub Desktop.
Save tathamoddie/7313428 to your computer and use it in GitHub Desktop.

git help {anything}

Find out about any command. For example, git help commit.

git init

Take the current folder, and turn it into a Git repo. (For when you're starting something new.)

Clone an existing repo to your local machine.

Will create the folder for you, based on the last part of the path. (In this case, foobar.)

git status

What branch am I currently on?

What changes do I have staged?

What changes are there in my working copy, but not yet staged?

git add foo.txt

Stage foo.txt

git add -A

Stage all the changes that are pending in my working copy

git commit -m "Fixed #123"

Commit your staged changes.

git commit -am "Fixed #123"

Stage all of the tracked files (but not new ones) in my working copy that have changes, then commit them all.

git log

Show the commit history (most recent first).

Note: when you run this, you're likely to have more than a screen's worth of content so Git will kick in vi as a pager. You'll know this because instead of returning to a new command line, your line will start with just :. You can keep hitting space to scroll down until you run out of content and get back to a command line, or just hit q to quit the pager.

git checkout -b my-feature

Create a new local branch called my-feature, then switch to it.

git push

Push the current branch to your default remote.

git pull

Pull the latest changes for this branch from your default remote, and automatically do a recursive merge if required.

git pull --rebase

Pull the latest changes for this branch from your default remote, and then try and rebase your work on top of them.

(Don't do this if you have any local commits)

git branch

Show all the local branches

gitk

Trigger a basic Windows browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment