SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
Git Cheat Sheet
Overview

Branch & Merge

When you first setup Git, set up your user name and email address so your first
commits record them properly.

Working with Git branches and the stash.

git config --global user.name "My Name"
git config --global user.email "user@email.com"

git branch

list your branches. a * will appear next to the
currently active branch

git branch [branch-name]

create a new branch at the current commit

GitHub is the best way to collaborate around your code. Fork, send pull requests
and manage all your public and private git repositories.

git checkout [branch]

switch to another branch and check it out into
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 deploying web apps.

git checkout -b [branch]

create a branch and immediately switch to it

git merge [branch]

merge another branch into your currently active
one and record the merge as a commit

About Git, GitHub and Heroku.
Git is a free & open source, distributed version control system designed to
handle everything from small to very large projects with speed and efficiency.

Basic Git Workflow Example
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 .
$ git commit -m 'initial commit'

git stash

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.

stash away the currently uncommitted
modifications in your working directory
temporarily

git stash apply

re-apply the last stashed changes

$
$
$
$
$

git branch featureA
git checkout featureA
(edit files)
git add (files)
git commit -m 'add feature A'

Share & Update
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)
$ git commit -a -m 'change files'

git fetch [alias]

fetch down all the branches from that Git remote

Merge the featureA changes into the master branch context, combining all your
work. Finally delete the featureA branch.

git merge [alias]/[branch]

merge a branch on the server into your currently
active branch to bring it up to date

git push [alias] [branch]

push the work on your branch to update that
branch on the remote git repository

git pull

fetch from the URL tracked by the current branch
and immediately try to merge in the tracked branch

$ git merge featureA
$ git branch -d featureA

Setup & Init
Git configuration, and repository initialization & cloning.
git config [key] [value]

set a config value in this repository

git config --global [key] [value]

set a config value globally for this user

git init

initialize an existing directory as a Git
repository

git clone [url]

clone a Git repository from a URL

git help [command]

get help on any Git command

Stage & Snapshot
Working with snapshots and the Git staging area.
git status

show the status of what is staged for your next commit and
what is modified in your working directory

git add [file]

add a file as it looks now to your next commit (stage)

git reset [file]

reset the staging area for a file so the change is not in your
next commit (unstage)

git diff

diff of what is changed but not staged

git diff --staged

diff of what is staged but not yet committed

git commit

commit your staged content as a new commit snapshot

git rm [file]

remove a file from your working directory and unstage

git gui

tcl/tk GUI program to make all of these commands simpler

Inspect & Compare
Examining logs, diffs and object information.
git log

show the commit history for the currently active
branch

git log branchB..branchA

show the commits on branchA that are not on
branchB

git log --follow [file]

show the commits that changed file, even across
renames

git diff branchB...branchA

show the diff of what is in branchA that is not in
branchB

git show [SHA]

show any object in Git in human-readable format

gitx

tcl/tk program to show the commit log in a GUI

http://git-scm.com
Contributing on GitHub

To contribute to a project that is 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.
fork project on github
$ git clone https://github.com/my-user/project
$ cd project

$ (edit files)

$ git add (files)

$ git commit -m 'Explain what I changed'
$ git push origin master

go to github and click ‘pull request’ button

Deploying to Heroku with Git
Use the heroku command-line tool to create an application and git remote:
$ heroku create
[Creating glowing-dusk-965... done, stack is bamboo-mri-1.9.2
http://glowing-dusk-965.heroku.com/ <http://glowing-dusk-965.
heroku.com/> | git@heroku.com:glowing-dusk-965.git <x-msg://536/
git@heroku.com:glowing-dusk-965.git> Git remote heroku added]

Use git to deploy the application.
$ git push heroku master

Create an additional Heroku app for staging, and name the git remote "staging".
$ heroku create my-staging-app --remote staging

Use git to deploy the application via the staging remote.
$ git push staging master

http://github.com

http://heroku.com

Copyright ©2011, salesforce.com, inc. All rights reserved. Salesforce.com and the “no software” logo are registered trademarks of salesforce.com, inc.,
and salesforce.com owns other registered and unregistered trademarks. Other names used herein may be trademarks of their respective owners.

082011

Contenu connexe

Tendances (20)

Introduction git
Introduction gitIntroduction git
Introduction git
 
BS5 - Lecture 1 Mechanical and Natural Ventilation
BS5 - Lecture 1 Mechanical and Natural VentilationBS5 - Lecture 1 Mechanical and Natural Ventilation
BS5 - Lecture 1 Mechanical and Natural Ventilation
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Github basics
Github basicsGithub basics
Github basics
 
Git slides
Git slidesGit slides
Git slides
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git e GitHub
Git e GitHubGit e GitHub
Git e GitHub
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Comparison of SVN and Git
Comparison of SVN and GitComparison of SVN and Git
Comparison of SVN and Git
 
Git basic
Git basicGit basic
Git basic
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
BitBucket Pull request vs Crucible
BitBucket Pull request vs CrucibleBitBucket Pull request vs Crucible
BitBucket Pull request vs Crucible
 
Dbn163 # 04. macro micro climate
Dbn163 # 04. macro micro climateDbn163 # 04. macro micro climate
Dbn163 # 04. macro micro climate
 
Git undo
Git undoGit undo
Git undo
 

En vedette

Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheetsynapsefre
 
Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Wen-Tien Chang
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git RightSven Peters
 
いつやるの?Git入門 v1.1.0
いつやるの?Git入門 v1.1.0いつやるの?Git入門 v1.1.0
いつやるの?Git入門 v1.1.0Masakazu Matsushita
 
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學littlebtc
 

En vedette (7)

Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheet
 
Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀
 
Git Tutorial 教學
Git Tutorial 教學Git Tutorial 教學
Git Tutorial 教學
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git Right
 
いつやるの?Git入門 v1.1.0
いつやるの?Git入門 v1.1.0いつやるの?Git入門 v1.1.0
いつやるの?Git入門 v1.1.0
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學
 

Similaire à Git Developer Cheatsheet

Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheetLam Hoang
 
GITHappens, powerpoint about git and github
GITHappens, powerpoint about git and githubGITHappens, powerpoint about git and github
GITHappens, powerpoint about git and githubalidor4702
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheetAbdul Basit
 
test
testtest
testzwned
 
Git cheat-sheet-education
Git cheat-sheet-educationGit cheat-sheet-education
Git cheat-sheet-educationssuser0bad24
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
introductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdfintroductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdfBruceLee275640
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheetJae Nwawe
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheetleo_priv00
 

Similaire à Git Developer Cheatsheet (20)

Git cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdfGit cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdf
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
GITHappens, powerpoint about git and github
GITHappens, powerpoint about git and githubGITHappens, powerpoint about git and github
GITHappens, powerpoint about git and github
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Git github
Git githubGit github
Git github
 
Git
GitGit
Git
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Git cheat-sheet-education
Git cheat-sheet-educationGit cheat-sheet-education
Git cheat-sheet-education
 
test
testtest
test
 
Git cheat-sheet-education
Git cheat-sheet-educationGit cheat-sheet-education
Git cheat-sheet-education
 
Techmoneyguide
TechmoneyguideTechmoneyguide
Techmoneyguide
 
git - the basics
git - the basicsgit - the basics
git - the basics
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git
GitGit
Git
 
introductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdfintroductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdf
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 

Plus de Abdul Basit

Atlassian git cheatsheet
Atlassian git cheatsheetAtlassian git cheatsheet
Atlassian git cheatsheetAbdul Basit
 
White box testing
White box testingWhite box testing
White box testingAbdul Basit
 
Testing the documentation
Testing the documentationTesting the documentation
Testing the documentationAbdul Basit
 
Testing software security
Testing software securityTesting software security
Testing software securityAbdul Basit
 
Testing fundamentals
Testing fundamentalsTesting fundamentals
Testing fundamentalsAbdul Basit
 
Test cases planning
Test cases planningTest cases planning
Test cases planningAbdul Basit
 
Software Testing
Software TestingSoftware Testing
Software TestingAbdul Basit
 
Software Compatibility testing
Software Compatibility testingSoftware Compatibility testing
Software Compatibility testingAbdul Basit
 
Black box testing
Black box testingBlack box testing
Black box testingAbdul Basit
 
Software Automated testing and tools
Software Automated testing and toolsSoftware Automated testing and tools
Software Automated testing and toolsAbdul Basit
 
Why test software
Why test softwareWhy test software
Why test softwareAbdul Basit
 
Static white box testing lecture 12
Static white box testing lecture 12Static white box testing lecture 12
Static white box testing lecture 12Abdul Basit
 
Software testing lecture 10
Software testing lecture 10Software testing lecture 10
Software testing lecture 10Abdul Basit
 
Software testing lecture 9
Software testing lecture 9Software testing lecture 9
Software testing lecture 9Abdul Basit
 
Software quality assurance lecture 1
Software quality assurance lecture 1Software quality assurance lecture 1
Software quality assurance lecture 1Abdul Basit
 
Software measurement lecture 7
Software measurement lecture 7Software measurement lecture 7
Software measurement lecture 7Abdul Basit
 
Planning for software quality assurance lecture 6
Planning for software quality assurance lecture 6Planning for software quality assurance lecture 6
Planning for software quality assurance lecture 6Abdul Basit
 
Managing software quality in an organization lecture 3
Managing software quality in an organization lecture 3Managing software quality in an organization lecture 3
Managing software quality in an organization lecture 3Abdul Basit
 

Plus de Abdul Basit (20)

Atlassian git cheatsheet
Atlassian git cheatsheetAtlassian git cheatsheet
Atlassian git cheatsheet
 
White box testing
White box testingWhite box testing
White box testing
 
Web testing
Web testingWeb testing
Web testing
 
Testing the documentation
Testing the documentationTesting the documentation
Testing the documentation
 
Testing software security
Testing software securityTesting software security
Testing software security
 
Testing fundamentals
Testing fundamentalsTesting fundamentals
Testing fundamentals
 
Test planning
Test planningTest planning
Test planning
 
Test cases planning
Test cases planningTest cases planning
Test cases planning
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Software Compatibility testing
Software Compatibility testingSoftware Compatibility testing
Software Compatibility testing
 
Black box testing
Black box testingBlack box testing
Black box testing
 
Software Automated testing and tools
Software Automated testing and toolsSoftware Automated testing and tools
Software Automated testing and tools
 
Why test software
Why test softwareWhy test software
Why test software
 
Static white box testing lecture 12
Static white box testing lecture 12Static white box testing lecture 12
Static white box testing lecture 12
 
Software testing lecture 10
Software testing lecture 10Software testing lecture 10
Software testing lecture 10
 
Software testing lecture 9
Software testing lecture 9Software testing lecture 9
Software testing lecture 9
 
Software quality assurance lecture 1
Software quality assurance lecture 1Software quality assurance lecture 1
Software quality assurance lecture 1
 
Software measurement lecture 7
Software measurement lecture 7Software measurement lecture 7
Software measurement lecture 7
 
Planning for software quality assurance lecture 6
Planning for software quality assurance lecture 6Planning for software quality assurance lecture 6
Planning for software quality assurance lecture 6
 
Managing software quality in an organization lecture 3
Managing software quality in an organization lecture 3Managing software quality in an organization lecture 3
Managing software quality in an organization lecture 3
 

Dernier

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 

Dernier (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Git Developer Cheatsheet

  • 1. Git Cheat Sheet Overview Branch & Merge When you first setup Git, set up your user name and email address so your first commits record them properly. Working with Git branches and the stash. git config --global user.name "My Name" git config --global user.email "user@email.com" git branch list your branches. a * will appear next to the currently active branch git branch [branch-name] create a new branch at the current commit GitHub is the best way to collaborate around your code. Fork, send pull requests and manage all your public and private git repositories. git checkout [branch] switch to another branch and check it out into 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 deploying web apps. git checkout -b [branch] create a branch and immediately switch to it git merge [branch] merge another branch into your currently active one and record the merge as a commit About Git, GitHub and Heroku. Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Basic Git Workflow Example 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 . $ git commit -m 'initial commit' git stash 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. stash away the currently uncommitted modifications in your working directory temporarily git stash apply re-apply the last stashed changes $ $ $ $ $ git branch featureA git checkout featureA (edit files) git add (files) git commit -m 'add feature A' Share & Update 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) $ git commit -a -m 'change files' git fetch [alias] fetch down all the branches from that Git remote Merge the featureA changes into the master branch context, combining all your work. Finally delete the featureA branch. git merge [alias]/[branch] merge a branch on the server into your currently active branch to bring it up to date git push [alias] [branch] push the work on your branch to update that branch on the remote git repository git pull fetch from the URL tracked by the current branch and immediately try to merge in the tracked branch $ git merge featureA $ git branch -d featureA Setup & Init Git configuration, and repository initialization & cloning. git config [key] [value] set a config value in this repository git config --global [key] [value] set a config value globally for this user git init initialize an existing directory as a Git repository git clone [url] clone a Git repository from a URL git help [command] get help on any Git command Stage & Snapshot Working with snapshots and the Git staging area. git status show the status of what is staged for your next commit and what is modified in your working directory git add [file] add a file as it looks now to your next commit (stage) git reset [file] reset the staging area for a file so the change is not in your next commit (unstage) git diff diff of what is changed but not staged git diff --staged diff of what is staged but not yet committed git commit commit your staged content as a new commit snapshot git rm [file] remove a file from your working directory and unstage git gui tcl/tk GUI program to make all of these commands simpler Inspect & Compare Examining logs, diffs and object information. git log show the commit history for the currently active branch git log branchB..branchA show the commits on branchA that are not on branchB git log --follow [file] show the commits that changed file, even across renames git diff branchB...branchA show the diff of what is in branchA that is not in branchB git show [SHA] show any object in Git in human-readable format gitx tcl/tk program to show the commit log in a GUI http://git-scm.com
  • 2. Contributing on GitHub To contribute to a project that is 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. fork project on github $ git clone https://github.com/my-user/project $ cd project $ (edit files) $ git add (files) $ git commit -m 'Explain what I changed' $ git push origin master go to github and click ‘pull request’ button Deploying to Heroku with Git Use the heroku command-line tool to create an application and git remote: $ heroku create [Creating glowing-dusk-965... done, stack is bamboo-mri-1.9.2 http://glowing-dusk-965.heroku.com/ <http://glowing-dusk-965. heroku.com/> | git@heroku.com:glowing-dusk-965.git <x-msg://536/ git@heroku.com:glowing-dusk-965.git> Git remote heroku added] Use git to deploy the application. $ git push heroku master Create an additional Heroku app for staging, and name the git remote "staging". $ heroku create my-staging-app --remote staging Use git to deploy the application via the staging remote. $ git push staging master http://github.com http://heroku.com Copyright ©2011, salesforce.com, inc. All rights reserved. Salesforce.com and the “no software” logo are registered trademarks of salesforce.com, inc., and salesforce.com owns other registered and unregistered trademarks. Other names used herein may be trademarks of their respective owners. 082011