Skip to content

Instantly share code, notes, and snippets.

@deeterETSF
Created February 24, 2014 15:27
Show Gist options
  • Save deeterETSF/9190388 to your computer and use it in GitHub Desktop.
Save deeterETSF/9190388 to your computer and use it in GitHub Desktop.
GitCommands
git config --global user.name "Tom Deeter"
git config --global user.email tdeeter@salesforce.com
git config --global color.ui true
mkdir name //make a directory
cd name //go inside the directory
git init
//initializes LOCAL Git repo at /Users/deeter/name/.git/
work / stage / commit
git status //tells us what has changed
git add filename.txt //adds file to "stage"
git commit -m "description of files added from stage"
//adds all staged files to local repo
git add --all //adds all files we are working on to stage
git log //see what you have commited
git add *.txt //adds all .txt files in current directory
git add "*.txt" //adds all .txt files in whole project
git add docs/ //adds all files in docs directory
git add docs/*.txt //adds all .txt files in docs directory
git diff /shows unstaged differences since last commit
git reset HEAD filename //removes file from stage, keeps intact
git checkout -- filename //removes file from stage, reverts
git commit -a -m "description of change to tracked files"
//stages then commits all tracked files that have changed
git reset --soft HEAD^
//reverts commit (do-over) and re-stages
git reset --hard HEAD^
//reverts commit, erases satge
git commit --amend -m "description of modification"
//amends previous commit with stage and overwrites description
REMOTE REPOSITORIES (Github)
git remote add <name> <url> //adds remote repo "bookmark"
git remote rm <name> /remove repo from Github
git remote -v
//shows remote repos
git push -u <name> master
//pushes local branch to root Github repo - asks for credentials
git push -u <name> <branch> //pushes branch to named repo
git pull
//pulls changes and syncs with local repo
git clone <url> rename
//copies repo to local in directory /rename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment