Skip to content

Instantly share code, notes, and snippets.

@donigian
Created June 24, 2012 17:23
Show Gist options
  • Save donigian/2984083 to your computer and use it in GitHub Desktop.
Save donigian/2984083 to your computer and use it in GitHub Desktop.
Common Git commands used for my projects
github setup
cd project_dir
git init
git add .
git commit -am 'initial commit'
git log
git remote add origin https://github.com/donigian/Hello-World.git
# Creates a remote named "origin" pointing at your GitHub repo
git push origin master
# Sends your commits in the "master" branch to GitHub
to rename a repo
git remote rm origin
no need to authenticate each time
$ git remote add origin git@github.com:someuser/newprojectname.git
git clone git://github.com/schacon/simplegit.git
git conflicts
git config --global alias.conflicts '!git ls-files -u | cut -f 2 | sort -u'
If you don't want to edit the config file by hand, you can use the command-line tool instead:
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master
Branch master set up to track remote branch master from origin.
git push -u origin master
if commits were not a on branch
git branch newbranch
git checkout master
git merge newbranch
changes between versions
diff --git
what changes have been introduced before running git commit (without -a)
git diff --staged
git diff --stat origin/master
view branches
git branch
new branch
git branch experiment
git checkout experiment
multiple devs same branch
git push origin experiment
merge with master
git merge experiment
delete branch
git branch -d experiment
setup remote repository
git clone *.git
pull changes from remote
git fetch origin
push changes
git push origin master
git remote rm origin
git remote -v
git remote add origin git@github.com/donigian/simpleWebApp.git
git remote add origin git@github.com:your_github_username/your_github_app.git
change author while preserving history
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='donigian'; GIT_AUTHOR_EMAIL='donigian at gmail.com'; GIT_COMMITTER_NAME='donigian'; GIT_COMMITTER_EMAIL='donigian at gmail.com';" HEAD
git pull origin master
git push origin master
http://cheat.errtheblog.com/s/git/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment