Created
June 24, 2012 17:23
-
-
Save donigian/2984083 to your computer and use it in GitHub Desktop.
Common Git commands used for my projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected]: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 [email protected]/donigian/simpleWebApp.git | |
git remote add origin [email protected]: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