0% found this document useful (0 votes)
84 views

SF Git Cheatsheet

Git is a version control system used to track changes to files and collaborate on code. GitHub is a platform to host Git repositories and collaborate remotely. Heroku is a platform to deploy web apps. The basic Git workflow involves initializing a repository, making changes, staging files, and committing snapshots of changes. Branches allow developing features independently and merging them together later. Remotes allow syncing changes with other repositories.

Uploaded by

Praveg Sinha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

SF Git Cheatsheet

Git is a version control system used to track changes to files and collaborate on code. GitHub is a platform to host Git repositories and collaborate remotely. Heroku is a platform to deploy web apps. The basic Git workflow involves initializing a repository, making changes, staging files, and committing snapshots of changes. Branches allow developing features independently and merging them together later. Remotes allow syncing changes with other repositories.

Uploaded by

Praveg Sinha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GIT Git Cheat Sheet

Overview Branch & Merge


When you first setup Git, set up your user name and email address so your first commits Working with Git branches and the stash.
record them properly.
git config --global user.name "My Name" list your branches. a * will appear next to the
git config --global user.email "[email protected]" git branch
currently active branch
About Git, GitHub and Heroku.
Git is a free and open source, distributed version control system designed to handle git branch [branch-name] create a new branch at the current commit
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 switch to another branch and check it out into
git checkout [branch]
manage all your public and private git repositories. your working directory

Heroku is a cloud application platform that supports a number of different programming


languages including Java, Ruby, Node.js, and Clojure—it's a new way of building and git checkout -b [branch] create a branch and immediately switch to it
deploying web apps.
merge another branch into your currently
git merge [branch]
Basic Git Workflow Example active one and record the merge as a commit
Initialize a new git repository, then stage all the files in the directory and finally commit the
initial snapshot. git log show commit logs
$ git init
$ git add . stash away the currently uncommitted
$ git commit -m 'initial commit' git stash modifications
Create a new branch named featureA, then check it out so it is the active branch. then edit in your working directory temporarily
and stage some files and finally commit the new snapshot.
$ git branch featureA git stash apply re-apply the last stashed changes
$ git checkout featureA
$
$
(edit files)
git add (files)
Share & Update
$ git commit -m 'add feature A' Fetching, merging and working with updates from another repository.
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 remote add [alias] [url] add a git URL as an alias
$ git checkout master
$ (edit files) fetch down all the branches from that Git
git fetch [alias]
$ git commit -a -m 'change files' remote
Merge the featureA changes into the master branch context, combining all your work.
Finally delete the featureA branch. merge a branch on the server into your
$ git merge featureA git merge [alias]/[branch]
currently active branch to bring it up to date
$ git branch -d featureA

Setup & Init push the work on your branch to update that
git push [alias] [branch]
Git configuration, and repository initialization and cloning. branch on the remote git repository

git config [key] [value] set a config value in this repository


fetch from the URL tracked by the current
git config --global [key] git pull branch and immediately try to merge in the
set a config value globally for this user
[value] tracked branch
initialize an existing directory as a
git init
Git repository Inspect & Compare
git clone [url] clone a Git repository from a URL
Examining logs, diffs and object information.
git help [command] get help on any Git command
show the commit history for the currently
git log
Stage & Snapshot active branch

Working with snapshots and the Git staging area. show the commits on branchA that are not
git log branchB..branchA
on branchB
show the status of what is staged for your next commit and what
git status
is modified in your working directory
show the commits that changed file, even
git log --follow [file]
git add [file] add a file as it looks now to your next commit (stage) across renames
reset the staging area for a file so the change is not in your next
git reset [file] show the diff of what is in branchA that is
commit (unstage) git diff branchB...branchA
not in branchB
git diff diff of what is changed but not staged
git diff --staged diff of what is staged but not yet committed show any object in Git in human-readable
git show [SHA]
format
git commit commit your staged content as a new commit snapshot
git rm [file] remove a file from your working directory and unstage tcl/tk program to show the commit log in
gitx
git gui
a GUI
tcl/tk GUI program to make all of these commands simpler

http://developer.salesforce.com
Contributing on GitHub Deploying to Heroku with Git
To contribute to a project hosted on GitHub you can fork the project on github.com, Use the heroku command-line tool to create an application and git remote:
then clone your fork locally, make a change, push back to GitHub, and then send a pull $ heroku create
request, which will email the maintainer.
[Creating glowing-dusk-965... done, stack is bamboo-mri-1.9.2
fork project on github http://glowing-dusk-965.heroku.com/ <http://glowing-dusk-965.
$ git clone https://github.com/my-user/project heroku.com/> | [email protected]:glowing-dusk-965.git <x-msg://536/
$ cd project [email protected]:glowing-dusk-965.git> Git remote heroku added]
$ (edit files)
Use git to deploy the application.
$ git add (files) $ git push heroku master
$ git commit -m 'Explain what I changed'
$ git push origin master Create an additional Heroku app for staging, and name the git remote "staging".
$ heroku create my-staging-app --remote staging
go to github and click ‘pull request’ button
Use git to deploy the application via the staging remote.
$ git push staging master

http://heroku.com

For other cheatsheets: http://developer.force.com/cheatsheets 11182013

You might also like