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

git-cheat-sheet

This Git Cheat Sheet provides a comprehensive overview of essential Git commands for workflows, local changes, collaboration, history, branches, stashing, tags, and writing good commit messages. It includes command descriptions for actions such as committing changes, managing branches, and interacting with remote repositories. The document is a useful reference for developers looking to streamline their use of Git.

Uploaded by

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

git-cheat-sheet

This Git Cheat Sheet provides a comprehensive overview of essential Git commands for workflows, local changes, collaboration, history, branches, stashing, tags, and writing good commit messages. It includes command descriptions for actions such as committing changes, managing branches, and interacting with remote repositories. The document is a useful reference for developers looking to streamline their use of Git.

Uploaded by

dolanhoffman
Copyright
© © All Rights Reserved
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
git reset HEAD <file> Unstage a file <branch> merge/integrate a remote branch
Start a new repository git checkout -- <file> Discard local changes in a file git push <remote> Upload local changes to a remote
Command Description <branch> repository
Create a new repository in the
git init
current directory
Branches git push <remote>
Delete a remote branch
--delete <branch>
Command Description
git clone <url> [<dir>] Clone a remote repository git push <remote> --tags Push tags to a remote repository
git branch List local branches

History git branch -r List remote branches


Stashing
Command Description 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
git stash
Show commit logs with one line Create a new branch and switch working directory away
git log --oneline git checkout -b <branch>
per commit to it
git stash list List all stashes
Show the changes of the last Merge a branch into the active
git show git merge <branch> git stash pop Apply the last stash and delete it
commit branch
git branch -d <branch> Delete a branch Apply the last stash but don't
Summarize git log output by git stash apply
git shortlog delete it
author
git stash drop Delete the last stash
git blame <file>
Show who changed which line in a Tags
file git stash clear Delete all stashes
Command Description
git tag List tags
Local changes Writing good commit messages
git tag <tag> Create a tag
Command Description
1. Separate subject from body with a blank line
git tag -a <tag> Create an annotated tag
List which files are staged, 2. Limit the subject line to 50 characters
git status
unstaged, and untracked git tag -s <tag> Create a GPG-signed tag 3. Capitalize the subject line
4. Do not end the subject line with a period
git add <file> Add a file to the staging area git tag -d <tag> Delete a tag
5. Use the imperative mood in the subject line
Interactively choose hunks of a git show <tag> Show the tag data 6. Wrap the body at 72 characters
git add -p
file to add to the staging area 7. Use the body to explain what and why vs. how

© Nth Root Software Consultancy: PHP & DevOps consulting - Last updated on July 25, 2024 - Find more cheat sheets at nth-root.nl/en/cheat-sheets

You might also like