SlideShare a Scribd company logo
1 of 5
Download to read offline
Git Reference      Support      Back to GitHub




Git cheat sheets
                                                                                                         Beginner
Cheat sheets
   Alexander Zeitler’s Git Cheat Sheet                                                                   Intermediate
   Zach Rusin’s Git Cheat Sheet
   http://cheat.errtheblog.com/s/git/                                                                    Advanced
   Nate Murray’s Git Cheat Sheet
   Git – Der Spickzettel (in German)                                                                     Troubleshooting
   DZone Git RefCard Cheat Sheet
   Sam Collett’s Git Cheat Sheet                                                                         Third party

A practical git guide                                                                                    GitHub Resources
Notes extracted from git screencast at http://www.peepcode.com.
                                                                                                         Git resources
Configuration
                                                                                                          Git cheat sheets

identify yourself to git: email and your name
                                                                                                         Pro Git
git config --global user.name "David Beckwith"
                                                                                                         Git SCM
git config --global user.email "dbitsolutions@gmail.com"
                                                                                                         Git Man Pages
To view all options:
                                                                                                         Git User Manual
git config --list
                                                                                                         Git Ready
OR
                                                                                                         Site policy
cat .git/config


Set up aliases
                                                                                                         This website is open source. Please help us by forking
                                                                                                         the project and adding to it.
git config --global alias.co checkout

View your configuration
                                                                                                         Site Status:    All systems operational
cat .gitconfig

To ignore whitespace (Ruby is whitespace insensitive)                                                    GitHub Tips                                     Next Tip

git config --global apply.whitespace nowarn
                                                                                                         Use embedded gists to add code snippets to your blog.
Some nice aliases:

gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status

Start using git

git init

Ignoring files

Add a file in the root directory called .gitignore and add some files to it: (comments begin
with hash)

*.log db/schema.rb db/schema.sql

Git automatically ignores empty directories. If you want to have a log/ directory, but want to
ignore all the files in it, add the following lines to the root .gitignore : (lines beginning with ‘!’
are exceptions)

log/*
!.gitignore

Then add an empty .gitignore in the empty directory:

touch log/.gitignore
Scheduling the addition of all files to the next commit

git add .


Checking the status of your repository

git status


Committing files

git commit -m "First import"

Seeing what files have been committed

git ls-files


Scheduling deletion of a file

git rm [file name]


Committing all changes in a repository

git commit -a


Scheduling the addition of an individual file to the next commit

git add [file name]


Viewing the difference as you commit

git commit -v


Commit and type the message on the command line

git commit -m "This is the message describing the commit"


Commit and automatically get any other changes

git commit -a

A “normal” commit command

git commit -a -v

Viewing a log of your commits

git log

Viewing a log of your commits with a graph to show the changes

git log --stat


Viewing a log with pagination

git log -v


Visualizing git changes

gitk --all


Creating a new tag and pushing it to the remote branch

git tag "v1.3"
git push --tags

Creating a new branch

git branch [name of your new branch]

Pushing the branch to a remote repository

git push origin [new-remote]


Pulling a new branch from a remote repository

git fetch origin [remote-branch]:[new-local-branch]


Viewing branches
git branch


Viewing a list of all existing branches

git branch -a


Switching to another branch

The state of your file system will change after executing this command.

git checkout [name of the branch you want to switch to]

OR

git co [name of the branch you want to switch to]

Making sure changes on master appear in your branch

git rebase master

Merging a branch back into the master branch

First, switch back to the master branch:

git co master

Check to see what changes you’re about to merge together, compare the two branches:

git diff master xyz

If you’re in a branch that’s not the xyz branch and want to merge the xyz branch into it:

git merge xyz


Reverting changes to before said merge

git reset --hard ORIG_HEAD

Resolving conflicts

Remove the markings, add the file, then commit.

Creating a branch (and switching to the new branch) in one line

git checkout -b [name of new branch]


Creating a stash (like a clipboard) of changes to allow you to switch branches without
committing

git stash save "Put a message here to remind you of what you're saving to the clipboard"


Switching from the current branch to another

git co [branch you want to switch to]

Do whatever
Then switch back to the stashed branch

git co [the stashed branch]

Viewing a list of stashes

git stash list

Loading back the stash

git stash apply

Now you can continue to work where you were previously.

Deleting a branch (that has been merged back at some point)

git branch -d [name of branch you want to delete]

Deleting an unmerged branch

git branch -D [name of branch you want to delete]

Deleting a stash

git stash clear
Setting up a repository for use on a remote server

Copy up your repository. e.g.:

scp -r my_project deploy@yourbox.com:my_project

Move your files on the remote server to /var/git/my_project
For security make the owner of this project git
On the repository server:

sudo chown -R git:git my_project

Then (for security) restrict the “deploy” user to doing git-related things in /etc/passwd with a
git-shell .

Checking out a git repository from a remote to your local storage

git clone git@yourbox.com:/var/git/my_project

Viewing extra info about a remote repository

cat .git/config

By virtue of having cloned the remote repository, your local repository becomes the slave and
will track and synchronize with the remote master branch.

Updating a local branch from the remote server

git pull


Downloading a copy of an entire repository (e.g. laptop) without merging into your local
branch

git fetch laptop

Merging two local branches (ie. your local xyz branch with your local master branch) USE
MERGE

git merge laptop/xyz

This merged the (already copied laptop repository’s xyz branch) with the current branch you’re
sitting in.

Viewing metadata about a remote repository

git remote show laptop


Pushing a committed local change from one local branch to another remote branch

git push laptop xyz


Creating a tracking branch (i.e. to link a local branch to a remote branch)

git branch --track local_branch remote_branch

You do not need to specify the local branch if you are already sitting in it.

git pull

Note: You can track(link) different local branches to different remote machines. For example,
you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and
simultaneously you can track the origin’s “master” branch (of your main webserver) with your
local “master” branch.

By convention, ‘origin’ is the local name given to the remote centralized server which is the way
SVN is usually set up on a remote server.

Seeing which local branches are tracking a remote branch

git remote show origin

Working with a remote Subversion repository (but with git locally)

git-svn clone [http location of an svn repository]

Now you can work with the checked out directory as though it was a git repository. (cuz it is)

Pushing (committing) changes to a remote Subversion repository

git-svn dcommit

Updating a local git repository from a remote Subversion repository
git-svn rebase

NOTE: make sure you have your perl bindings to your local svn installation.

I screwed up, how do I reset my checkout?

git checkout -f


See also
   Git   for computer scientists.
   Git   user’s manual
   Git   Magic
   Git   Cheat Sheets Collection on DevCheatSheet.com




                             GitHub                         Tools               Extras

                             About                          GitHub for Mac      Shop
                             Blog                           Gist                The Octodex
                             Contact & Support              GitHub Enterprise
                             Training                       Job Board
                             Site Status




                             Terms of Service Privacy Security
                             © 2012 GitHub Inc. All rights reserved.

More Related Content

What's hot

Git Terminologies
Git TerminologiesGit Terminologies
Git TerminologiesYash
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsth507
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubBigBlueHat
 
Git workshop 33degree 2011 krakow
Git workshop 33degree 2011 krakowGit workshop 33degree 2011 krakow
Git workshop 33degree 2011 krakowLuca Milanesio
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-realEneldo Serrata
 
Git 101 Workshop
Git 101 WorkshopGit 101 Workshop
Git 101 WorkshopJoy Seng
 

What's hot (20)

Git Basic
Git BasicGit Basic
Git Basic
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
 
setting up a repository using GIT
setting up a repository using GITsetting up a repository using GIT
setting up a repository using GIT
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git & git hub
Git & git hubGit & git hub
Git & git hub
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Git workshop 33degree 2011 krakow
Git workshop 33degree 2011 krakowGit workshop 33degree 2011 krakow
Git workshop 33degree 2011 krakow
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-real
 
Git 101 Workshop
Git 101 WorkshopGit 101 Workshop
Git 101 Workshop
 
Git github
Git githubGit github
Git github
 
Git Real
Git RealGit Real
Git Real
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 

Viewers also liked

Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheetAbdul Basit
 
What Can Social Media Do for You by Dina Lima
What Can Social Media Do for You by Dina LimaWhat Can Social Media Do for You by Dina Lima
What Can Social Media Do for You by Dina LimaDina Lima
 
Ufone prepaid
Ufone prepaidUfone prepaid
Ufone prepaidUfone
 
Hoe Downloads In Mijn Game Zetten
Hoe Downloads In Mijn Game ZettenHoe Downloads In Mijn Game Zetten
Hoe Downloads In Mijn Game Zettenguest187821
 
Israel (Actualizada) Sct
Israel (Actualizada) SctIsrael (Actualizada) Sct
Israel (Actualizada) Sctpenderyn
 
Social Media GLAM
Social Media GLAMSocial Media GLAM
Social Media GLAMJosh Peters
 
Pomodoro Technique. How not to be distracted at work?
Pomodoro Technique. How not to be distracted at work?Pomodoro Technique. How not to be distracted at work?
Pomodoro Technique. How not to be distracted at work?Dmitry Kandalov
 
Study Notes Dolmecia Crayton
Study Notes Dolmecia CraytonStudy Notes Dolmecia Crayton
Study Notes Dolmecia Craytonmeci4life
 
Making FAIL More FUN - short version now with added sheep.
Making FAIL More FUN - short version now with added sheep.Making FAIL More FUN - short version now with added sheep.
Making FAIL More FUN - short version now with added sheep.Dawa Riley
 

Viewers also liked (20)

Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Git flow cheatsheet
Git flow cheatsheetGit flow cheatsheet
Git flow cheatsheet
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
PIRC 101
PIRC 101PIRC 101
PIRC 101
 
Engage! V6
Engage! V6Engage! V6
Engage! V6
 
07compar
07compar07compar
07compar
 
What Can Social Media Do for You by Dina Lima
What Can Social Media Do for You by Dina LimaWhat Can Social Media Do for You by Dina Lima
What Can Social Media Do for You by Dina Lima
 
Ufone prepaid
Ufone prepaidUfone prepaid
Ufone prepaid
 
Hoe Downloads In Mijn Game Zetten
Hoe Downloads In Mijn Game ZettenHoe Downloads In Mijn Game Zetten
Hoe Downloads In Mijn Game Zetten
 
Israel (Actualizada) Sct
Israel (Actualizada) SctIsrael (Actualizada) Sct
Israel (Actualizada) Sct
 
Engage! V6
Engage! V6Engage! V6
Engage! V6
 
Social Media GLAM
Social Media GLAMSocial Media GLAM
Social Media GLAM
 
Kirli Uzlasma
Kirli UzlasmaKirli Uzlasma
Kirli Uzlasma
 
Facts About Me
Facts About MeFacts About Me
Facts About Me
 
Pomodoro Technique. How not to be distracted at work?
Pomodoro Technique. How not to be distracted at work?Pomodoro Technique. How not to be distracted at work?
Pomodoro Technique. How not to be distracted at work?
 
Digital
DigitalDigital
Digital
 
Study Notes Dolmecia Crayton
Study Notes Dolmecia CraytonStudy Notes Dolmecia Crayton
Study Notes Dolmecia Crayton
 
Making FAIL More FUN - short version now with added sheep.
Making FAIL More FUN - short version now with added sheep.Making FAIL More FUN - short version now with added sheep.
Making FAIL More FUN - short version now with added sheep.
 
Spy on-yourself
Spy on-yourselfSpy on-yourself
Spy on-yourself
 
Ruke
RukeRuke
Ruke
 

Similar to Git cheat-sheets

Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?9 series
 
Git slides
Git slidesGit slides
Git slidesNanyak S
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 
Learn Git Fundamentals
Learn Git FundamentalsLearn Git Fundamentals
Learn Git FundamentalsJatin Sharma
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheetLam Hoang
 
Getting Started with Git
Getting Started with GitGetting Started with Git
Getting Started with GitRick Umali
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get GitSusan Tan
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with gitDídac Ríos
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 

Similar to Git cheat-sheets (20)

Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git slides
Git slidesGit slides
Git slides
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Learn Git Fundamentals
Learn Git FundamentalsLearn Git Fundamentals
Learn Git Fundamentals
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Getting Started with Git
Getting Started with GitGetting Started with Git
Getting Started with Git
 
simple Git
simple Git simple Git
simple Git
 
Git training
Git trainingGit training
Git training
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with git
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Git cheat-sheets

  • 1. Git Reference Support Back to GitHub Git cheat sheets Beginner Cheat sheets Alexander Zeitler’s Git Cheat Sheet Intermediate Zach Rusin’s Git Cheat Sheet http://cheat.errtheblog.com/s/git/ Advanced Nate Murray’s Git Cheat Sheet Git – Der Spickzettel (in German) Troubleshooting DZone Git RefCard Cheat Sheet Sam Collett’s Git Cheat Sheet Third party A practical git guide GitHub Resources Notes extracted from git screencast at http://www.peepcode.com. Git resources Configuration Git cheat sheets identify yourself to git: email and your name Pro Git git config --global user.name "David Beckwith" Git SCM git config --global user.email "dbitsolutions@gmail.com" Git Man Pages To view all options: Git User Manual git config --list Git Ready OR Site policy cat .git/config Set up aliases This website is open source. Please help us by forking the project and adding to it. git config --global alias.co checkout View your configuration Site Status: All systems operational cat .gitconfig To ignore whitespace (Ruby is whitespace insensitive) GitHub Tips Next Tip git config --global apply.whitespace nowarn Use embedded gists to add code snippets to your blog. Some nice aliases: gb = git branch gba = git branch -a gc = git commit -v gd = git diff | mate gl = git pull gp = git push gst = git status Start using git git init Ignoring files Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash) *.log db/schema.rb db/schema.sql Git automatically ignores empty directories. If you want to have a log/ directory, but want to ignore all the files in it, add the following lines to the root .gitignore : (lines beginning with ‘!’ are exceptions) log/* !.gitignore Then add an empty .gitignore in the empty directory: touch log/.gitignore
  • 2. Scheduling the addition of all files to the next commit git add . Checking the status of your repository git status Committing files git commit -m "First import" Seeing what files have been committed git ls-files Scheduling deletion of a file git rm [file name] Committing all changes in a repository git commit -a Scheduling the addition of an individual file to the next commit git add [file name] Viewing the difference as you commit git commit -v Commit and type the message on the command line git commit -m "This is the message describing the commit" Commit and automatically get any other changes git commit -a A “normal” commit command git commit -a -v Viewing a log of your commits git log Viewing a log of your commits with a graph to show the changes git log --stat Viewing a log with pagination git log -v Visualizing git changes gitk --all Creating a new tag and pushing it to the remote branch git tag "v1.3" git push --tags Creating a new branch git branch [name of your new branch] Pushing the branch to a remote repository git push origin [new-remote] Pulling a new branch from a remote repository git fetch origin [remote-branch]:[new-local-branch] Viewing branches
  • 3. git branch Viewing a list of all existing branches git branch -a Switching to another branch The state of your file system will change after executing this command. git checkout [name of the branch you want to switch to] OR git co [name of the branch you want to switch to] Making sure changes on master appear in your branch git rebase master Merging a branch back into the master branch First, switch back to the master branch: git co master Check to see what changes you’re about to merge together, compare the two branches: git diff master xyz If you’re in a branch that’s not the xyz branch and want to merge the xyz branch into it: git merge xyz Reverting changes to before said merge git reset --hard ORIG_HEAD Resolving conflicts Remove the markings, add the file, then commit. Creating a branch (and switching to the new branch) in one line git checkout -b [name of new branch] Creating a stash (like a clipboard) of changes to allow you to switch branches without committing git stash save "Put a message here to remind you of what you're saving to the clipboard" Switching from the current branch to another git co [branch you want to switch to] Do whatever Then switch back to the stashed branch git co [the stashed branch] Viewing a list of stashes git stash list Loading back the stash git stash apply Now you can continue to work where you were previously. Deleting a branch (that has been merged back at some point) git branch -d [name of branch you want to delete] Deleting an unmerged branch git branch -D [name of branch you want to delete] Deleting a stash git stash clear
  • 4. Setting up a repository for use on a remote server Copy up your repository. e.g.: scp -r my_project deploy@yourbox.com:my_project Move your files on the remote server to /var/git/my_project For security make the owner of this project git On the repository server: sudo chown -R git:git my_project Then (for security) restrict the “deploy” user to doing git-related things in /etc/passwd with a git-shell . Checking out a git repository from a remote to your local storage git clone git@yourbox.com:/var/git/my_project Viewing extra info about a remote repository cat .git/config By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch. Updating a local branch from the remote server git pull Downloading a copy of an entire repository (e.g. laptop) without merging into your local branch git fetch laptop Merging two local branches (ie. your local xyz branch with your local master branch) USE MERGE git merge laptop/xyz This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in. Viewing metadata about a remote repository git remote show laptop Pushing a committed local change from one local branch to another remote branch git push laptop xyz Creating a tracking branch (i.e. to link a local branch to a remote branch) git branch --track local_branch remote_branch You do not need to specify the local branch if you are already sitting in it. git pull Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch. By convention, ‘origin’ is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server. Seeing which local branches are tracking a remote branch git remote show origin Working with a remote Subversion repository (but with git locally) git-svn clone [http location of an svn repository] Now you can work with the checked out directory as though it was a git repository. (cuz it is) Pushing (committing) changes to a remote Subversion repository git-svn dcommit Updating a local git repository from a remote Subversion repository
  • 5. git-svn rebase NOTE: make sure you have your perl bindings to your local svn installation. I screwed up, how do I reset my checkout? git checkout -f See also Git for computer scientists. Git user’s manual Git Magic Git Cheat Sheets Collection on DevCheatSheet.com GitHub Tools Extras About GitHub for Mac Shop Blog Gist The Octodex Contact & Support GitHub Enterprise Training Job Board Site Status Terms of Service Privacy Security © 2012 GitHub Inc. All rights reserved.