0% found this document useful (0 votes)
17 views1 page

git-cheat-sheet

Uploaded by

demy2014
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

git-cheat-sheet

Uploaded by

demy2014
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Git Cheat Sheet

Workflow Local changes (cont.) Collaboration


Command Description Command Description
git diff Show unstaged changes git remote -v List remote repositories
git diff --staged Show staged changes git remote add <name>
Add a new remote repository
<url>
Commit staged changes using the
git commit
default editor Download all changes from a
git fetch <remote> remote repository but don't
Commit staged changes with a integrate them
git commit -m <message> message provided on the
command line Download changes and directly
git pull <remote>
merge/integrate them
git commit --amend Amend the last commit
git pull <remote> Download changes and directly
Start a new repository git reset HEAD <file> Unstage a file <branch> merge/integrate a remote branch
Command Description git checkout -- <file> Discard local changes in a file git push <remote> Upload local changes to a remote
<branch> repository
Create a new repository in the
git init
current directory Branches git push <remote>
Delete a remote branch
--delete <branch>
git clone <url> [<dir>] Clone a remote repository Command Description
git push <remote> --tags Push tags to a remote repository
git branch List local branches
History git branch -r List remote branches
Command Description
Stashing
git branch <branch> Create a new branch
Command Description
git log Show commit logs
git checkout <branch> Switch to a branch
Stash the changes in a dirty
Show commit logs with one line git stash
git log --oneline Create a new branch and switch working directory away
per commit git checkout -b <branch>
to it
git stash list List all stashes
Show the changes of the last
git show Merge a branch into the active
commit git merge <branch> git stash pop Apply the last stash and delete it
branch
Summarize git log output by Apply the last stash but don't
git shortlog git branch -d <branch> Delete a branch git stash apply
author delete it
Show who changed which line in a git stash drop Delete the last stash
git blame <file>
file Tags
git stash clear Delete all stashes
Command Description

Local changes git tag List tags


Writing good commit messages
Command Description git tag <tag> Create a tag
1. Separate subject from body with a blank line
List which files are staged, git tag -a <tag> Create an annotated tag
git status 2. Limit the subject line to 50 characters
unstaged, and untracked
git tag -s <tag> Create a GPG-signed tag 3. Capitalize the subject line
git add <file> Add a file to the staging area 4. Do not end the subject line with a period
git tag -d <tag> Delete a tag
Interactively choose hunks of a 5. Use the imperative mood in the subject line
git add -p git show <tag> Show the tag data 6. Wrap the body at 72 characters
file to add to the staging area
7. Use the body to explain what and why vs. how

© Nic Wortel, Software Consultant & Trainer - Last updated on July 25, 2024 - Find more cheat sheets at https://nicwortel.nl/cheat-sheets

You might also like