Git Cheatsheet
Git Cheatsheet
GIT
Overview
When you first setup Git, set up your user name and email address so your first commits
record them properly.
git branch
Git is a free and open source, distributed version control system designed to handle
everything from small to very large projects with speed and efficiency.
GitHub is the best way to collaborate around your code. Fork, send pull requests, and
manage all your public and private git repositories.
git log
git stash
Initialize a new git repository, then stage all the files in the directory and finally commit the
initial snapshot.
$ git init
$ git add .
$ git commit -m 'initial commit'
Create a new branch named featureA, then check it out so it is the active branch. then edit
and stage some files and finally commit the new snapshot.
$
$
$
$
$
Switch back to the master branch, reverting the featureA changes you just made, then edit
some files and commit your new changes directly in the master branch context.
git pull
git init
Merge the featureA changes into the master branch context, combining all your work.
Finally delete the featureA branch.
$ git merge featureA
$ git branch -d featureA
git status
show the status of what is staged for your next commit and what
is modified in your working directory
reset the staging area for a file so the change is not in your next
commit (unstage)
git diff
git commit
git rm [file]
git gui
gitx
http://developer.salesforce.com
Contributing on GitHub
To contribute to a project hosted on GitHub you can fork the project on github.com,
then clone your fork locally, make a change, push back to GitHub, and then send a pull
request, which will email the maintainer.
Use the heroku command-line tool to create an application and git remote:
$ (edit files)
$ heroku create
Create an additional Heroku app for staging, and name the git remote "staging".
$ heroku create my-staging-app --remote staging
http://heroku.com
11182013