Skip to content

Instantly share code, notes, and snippets.

@RATTLESNAKE-VIPER
Created July 29, 2012 15:18
Show Gist options
  • Save RATTLESNAKE-VIPER/3199445 to your computer and use it in GitHub Desktop.
Save RATTLESNAKE-VIPER/3199445 to your computer and use it in GitHub Desktop.
Git Commands Quick Lookup
-----------------------------------------------SET UP GIT-----------------------------------------------
Username:
git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit
Email:
git config --global user.email "your_email@youremail.com"
# Sets the default email for git to use when you commit
# Your email address for Git should be the same one associated with your GitHub account.
Check current config:
git config -l
---------------------------------------------------BASICS-------------------------------------------
git init
git status
git log | git log --summary
git add <filename> | git add . | git add '*.txt'
git rm -f <filename>
git commit -m "commit message"
git remote add origin repository-URL
git push -u origin master (The name of our remote is origin and the default local branch name is master.)
git pull origin master
git diff HEAD
git diff --staged
git reset <filename> (Unstage files / Reseting the stage)
git checkout -- <target|filename> (Undo)
git branch
git branch <branch>
git checkout <branch> (Switching Branches)
git merge <branch>
git branch -d <branch> (Deleting Branch)
Restoring lost commits (http://gitready.com/advanced/2009/01/17/restoring-lost-commits.html)
$ git show-ref -h HEAD
7c61179cbe51c050c5520b4399f7b14eec943754 HEAD
$ git reset --hard HEAD^
HEAD is now at 39ba87b Fixing about and submit pages so they don't look stupid
$ git show-ref -h HEAD
39ba87bf28b5bb223feffafb59638f6f46908cac HEAD
----------------------------------------------GIT SVN------------------------------------------------
# checkout a specific revision
git svn clone -r N svn://some/repo/branch/some-branch
# enter it and get all commits since revision 'N'
cd some-branch
git svn rebase
----------------------------------------------ADDITIONAL------------------------------------------------
git clone []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment