Top Related Projects
A list of cool features of Git and GitHub.
Most commonly used git tips and tricks.
Flight rules for git
git - the simple guide
Quick Overview
The arslanbilal/git-cheat-sheet repository is a comprehensive collection of Git commands and best practices. It serves as a quick reference guide for developers of all skill levels, providing explanations and examples for various Git operations in multiple languages.
Pros
- Extensive coverage of Git commands and concepts
- Available in multiple languages, making it accessible to a global audience
- Regularly updated with new Git features and best practices
- Well-organized and easy to navigate
Cons
- May be overwhelming for absolute beginners due to the sheer amount of information
- Some language translations might not be as up-to-date as the English version
- Lacks interactive elements or practical exercises for hands-on learning
- Could benefit from more visual aids or diagrams to explain complex Git concepts
Code Examples
This repository is not a code library but a reference guide, so code examples are not applicable in the traditional sense. However, here are a few examples of Git commands from the cheat sheet:
# Initialize a new Git repository
git init
# Clone a remote repository
git clone <repository-url>
# Create a new branch and switch to it
git checkout -b <branch-name>
Getting Started
As this is a reference guide and not a code library, there's no need for installation or setup. To use the Git cheat sheet:
- Visit the repository: https://github.com/arslanbilal/git-cheat-sheet
- Choose your preferred language from the available translations
- Browse the contents or use the table of contents to find specific Git commands or concepts
- Bookmark the page for quick access during your development work
Competitor Comparisons
A list of cool features of Git and GitHub.
Pros of github-cheat-sheet
- More comprehensive coverage of GitHub-specific features and workflows
- Includes advanced topics like GitHub Actions, GitHub Pages, and API usage
- Regularly updated with new GitHub features and best practices
Cons of github-cheat-sheet
- Less focus on core Git commands and concepts
- May be overwhelming for beginners due to its extensive content
- Requires more time to navigate and find specific information
Code Comparison
git-cheat-sheet:
git init
git add .
git commit -m "Initial commit"
github-cheat-sheet:
# Create a new repository on GitHub
curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'
# Create a new file in the repository
curl -u 'USER' -X PUT -d '{"message":"Create file","content":"BASE64_ENCODED_CONTENT"}' https://api.github.com/repos/USER/REPO/contents/PATH
The git-cheat-sheet focuses on basic Git commands, while the github-cheat-sheet demonstrates more advanced GitHub-specific operations using the API.
Both repositories serve as valuable resources for developers, with git-cheat-sheet being more suitable for Git beginners and github-cheat-sheet catering to those looking to leverage GitHub's advanced features and integrations.
Most commonly used git tips and tricks.
Pros of tips
- More comprehensive collection of Git tips and tricks
- Regularly updated with new content and contributions
- Includes advanced Git techniques and lesser-known commands
Cons of tips
- Less structured organization compared to git-cheat-sheet
- May be overwhelming for Git beginners due to the sheer volume of information
- Lacks visual aids or diagrams to explain complex concepts
Code comparison
tips:
git log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=short
git-cheat-sheet:
git log --oneline --graph --decorate
Both repositories provide useful Git commands, but tips offers a more customized and detailed log output, while git-cheat-sheet focuses on a simpler, graphical representation of the commit history.
Flight rules for git
Pros of git-flight-rules
- More comprehensive and detailed explanations
- Covers a wider range of Git scenarios and edge cases
- Regularly updated with new content and contributions
Cons of git-flight-rules
- Can be overwhelming for beginners due to its extensive content
- Less visually appealing and harder to quickly scan for information
- Requires more time to find specific commands or solutions
Code comparison
git-flight-rules:
git config --global alias.undo-commit 'reset --soft HEAD^'
git config --global alias.visual '!gitk'
git-cheat-sheet:
git reset --soft HEAD~1
gitk
git-flight-rules provides more detailed explanations and examples for each command, while git-cheat-sheet offers a more concise and quick-reference format. git-flight-rules is better suited for in-depth learning and troubleshooting, whereas git-cheat-sheet is ideal for quick lookups and refreshers on common Git commands.
Both repositories serve as valuable resources for Git users, with git-flight-rules being more comprehensive and git-cheat-sheet being more accessible for quick reference. The choice between the two depends on the user's needs and level of Git expertise.
git - the simple guide
Pros of git-guide
- Simple, concise, and easy to understand for beginners
- Provides a quick overview of essential Git commands
- Includes a visual representation of Git workflow
Cons of git-guide
- Less comprehensive than git-cheat-sheet
- Lacks explanations for more advanced Git concepts
- Not regularly updated (last update in 2016)
Code Comparison
git-guide:
git init
git clone /path/to/repository
git add <filename>
git commit -m "Commit message"
git push origin master
git-cheat-sheet:
git init [project-name]
git clone [url]
git add [file]
git commit -m "[descriptive message]"
git push [alias] [branch]
Both repositories provide similar basic Git commands, but git-cheat-sheet offers more detailed explanations and covers a wider range of Git operations. git-guide focuses on simplicity and visual representation, making it more suitable for absolute beginners, while git-cheat-sheet serves as a more comprehensive reference for both beginners and intermediate users.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Git and Git Flow Cheat Sheet
ð About
This comprehensive Git cheat sheet helps you master Git commands without memorizing everything. Whether you're a beginner or an experienced developer, this guide provides quick reference to essential Git operations.
Contributions Welcome! Feel free to:
- Fix grammar mistakes
- Add new commands
- Translate to your language
- Improve explanations
ð Table of Contents
- ð§ Setup
- âï¸ Configuration Files
- ð Create Repository
- ð Local Changes
- ð Search
- ð Commit History
- ð Move / Rename
- ð¿ Branches & Tags
- ð Update & Publish
- ð Merge & Rebase
- â©ï¸ Undo
- ð Git Flow
- ð Other Languages
ð§ Setup
View Configuration
Show current configuration:
git config --list
Show repository configuration:
git config --local --list
Show global configuration:
git config --global --list
Show system configuration:
git config --system --list
User Configuration
Set your name for version history:
git config --global user.name "[firstname lastname]"
Set your email address:
git config --global user.email "[valid-email]"
Display & Editor Settings
Enable automatic command line coloring:
git config --global color.ui auto
Set global editor for commits:
git config --global core.editor vi
âï¸ Configuration Files
Scope | Location | Command Flag |
---|---|---|
Repository | <repo>/.git/config | --local |
User | ~/.gitconfig | --global |
System | /etc/gitconfig | --system |
ð Create Repository
Clone Existing Repository
Via SSH:
git clone ssh://user@domain.com/repo.git
Via HTTPS:
git clone https://domain.com/user/repo.git
Initialize New Repository
Create repository in current directory:
git init
Create repository in specific directory:
git init <directory>
ð Local Changes
Check Status & Differences
View working directory status:
git status
Show changes to tracked files:
git diff
Show changes in specific file:
git diff <file>
Staging Changes
Add all current changes:
git add .
Add specific files:
git add <filename1> <filename2>
Interactively add parts of a file:
git add -p <file>
Committing Changes
Commit all tracked file changes:
git commit -a
Commit staged changes:
git commit
Commit with message:
git commit -m 'message here'
Skip staging and commit with message:
git commit -am 'message here'
Commit with specific date:
git commit --date="`date --date='n day ago'`" -am "<Commit Message Here>"
Modify Last Commit
â ï¸ Warning: Don't amend published commits!
Amend last commit:
git commit -a --amend
Amend without changing commit message:
git commit --amend --no-edit
Change committer date:
GIT_COMMITTER_DATE="date" git commit --amend
Change author date:
git commit --amend --date="date"
Stashing Changes
Save current changes temporarily:
git stash
Apply last stashed changes:
git stash apply
Apply specific stash:
git stash apply stash@{stash_number}
Use
git stash list
to see available stashes
Remove last stash:
git stash drop
Move uncommitted changes to another branch:
git stash
git checkout branch2
git stash pop
ð Search
Text Search
Search for text in all files:
git grep "Hello"
Search in specific version:
git grep "Hello" v2.5
Commit Search
Find commits that introduced specific keyword:
git log -S 'keyword'
Search with regular expression:
git log -S 'keyword' --pickaxe-regex
ð Commit History
Basic History
Show all commits (detailed):
git log
Show commits (one line each):
git log --oneline
Show commits by specific author:
git log --author="username"
Show changes for specific file:
git log -p <file>
Advanced History
Compare branches:
git log --oneline <origin/master>..<remote/master> --left-right
Show who changed what and when:
git blame <file>
Reference Logs
Show reference log:
git reflog show
Delete reference log:
git reflog delete
ð Move / Rename
Rename a file:
git mv Index.txt Index.html
ð¿ Branches & Tags
List Branches
List local branches:
git branch
List all branches (local + remote):
git branch -a
List remote branches:
git branch -r
List merged branches:
git branch --merged
Switch & Create Branches
Switch to existing branch:
git checkout <branch>
Create and switch to new branch:
git checkout -b <branch>
Switch to previous branch:
git checkout -
Create branch from existing branch:
git checkout -b <new_branch> <existing_branch>
Create branch from specific commit:
git checkout <commit-hash> -b <new_branch_name>
Create branch without switching:
git branch <new-branch>
Create tracking branch:
git branch --track <new-branch> <remote-branch>
Branch Operations
Checkout single file from different branch:
git checkout <branch> -- <filename>
Apply specific commit from another branch:
git cherry-pick <commit hash>
Rename current branch:
git branch -m <new_branch_name>
Delete local branch:
git branch -d <branch>
Force delete local branch:
git branch -D <branch>
â ï¸ Warning: You will lose unmerged changes!
Tags
Create tag at HEAD:
git tag <tag-name>
Create annotated tag:
git tag -a <tag-name>
Create tag with message:
git tag <tag-name> -am 'message here'
List all tags:
git tag
List tags with messages:
git tag -n
ð Update & Publish
Remote Management
List configured remotes:
git remote -v
Show remote information:
git remote show <remote>
Add new remote:
git remote add <remote> <url>
Rename remote:
git remote rename <remote> <new_remote>
Remove remote:
git remote rm <remote>
â¹ï¸ Note: This only removes the remote reference locally, not the remote repository itself.
Fetch & Pull
Download changes without merging:
git fetch <remote>
Download and merge changes:
git pull <remote> <branch>
Get changes from main branch:
git pull origin master
Pull with rebase:
git pull --rebase <remote> <branch>
Push & Publish
Publish local changes:
git push <remote> <branch>
Delete remote branch:
# Git v1.7.0+
git push <remote> --delete <branch>
# Git v1.5.0+
git push <remote> :<branch>
Publish tags:
git push --tags
ð Merge & Rebase
Merge Operations
Merge branch into current HEAD:
git merge <branch>
Configure merge tool globally:
git config --global merge.tool meld
Use configured merge tool:
git mergetool
Rebase Operations
â ï¸ Warning: Don't rebase published commits!
Rebase current HEAD onto branch:
git rebase <branch>
Abort rebase:
git rebase --abort
Continue rebase after resolving conflicts:
git rebase --continue
Conflict Resolution
Mark file as resolved:
git add <resolved-file>
Remove resolved file:
git rm <resolved-file>
Squashing Commits
Interactive rebase for squashing:
git rebase -i <commit-just-before-first>
Example squash configuration:
# Before
pick <commit_id>
pick <commit_id2>
pick <commit_id3>
# After (squash commit_id2 and commit_id3 into commit_id)
pick <commit_id>
squash <commit_id2>
squash <commit_id3>
â©ï¸ Undo
Discard Changes
Discard all local changes:
git reset --hard HEAD
Unstage all files:
git reset HEAD
Discard changes in specific file:
git checkout HEAD <file>
Reset Operations
Reset to previous commit (discard all changes):
git reset --hard <commit>
Reset to remote branch state:
git reset --hard <remote/branch>
# Example: git reset --hard upstream/master
Reset preserving changes as unstaged:
git reset <commit>
Reset preserving uncommitted local changes:
git reset --keep <commit>
Revert Commits
Revert commit (create new commit with opposite changes):
git revert <commit>
Clean Ignored Files
Remove accidentally committed files that should be ignored:
git rm -r --cached .
git add .
git commit -m "remove ignored files"
ð Git Flow
Improved Git-flow: git-flow-avh
ð Table of Contents
- ð§ Setup
- ð Getting Started
- ⨠Features
- ð Make a Release
- ð¥ Hotfixes
- ð Commands Overview
ð§ Setup {#setup-1}
Prerequisite: Working Git installation required. Git-flow works on macOS, Linux, and Windows.
macOS (Homebrew):
brew install git-flow-avh
macOS (MacPorts):
port install git-flow
Linux (Debian-based):
sudo apt-get install git-flow
Windows (Cygwin):
Requires wget and util-linux
wget -q -O - --no-check-certificate https://raw.githubusercontent.com/petervanderdoes/gitflow/develop/contrib/gitflow-installer.sh install <state> | bash
ð Getting Started
Git-flow needs initialization to customize your project setup.
Initialize (interactive):
git flow init
You'll answer questions about branch naming conventions. Default values are recommended.
Initialize (use defaults):
git flow init -d
⨠Features
Features are for developing new functionality for upcoming releases. They typically exist only in developer repositories.
Start new feature:
git flow feature start MYFEATURE
Creates feature branch based on 'develop' and switches to it
Finish feature:
git flow feature finish MYFEATURE
This will:
- Merge MYFEATURE into 'develop'
- Remove the feature branch
- Switch back to 'develop'
Publish feature (for collaboration):
git flow feature publish MYFEATURE
Get published feature:
git flow feature pull origin MYFEATURE
Track origin feature:
git flow feature track MYFEATURE
ð Make a Release
Releases support preparation of new production releases, allowing minor bug fixes and preparing meta-data.
Start release:
git flow release start RELEASE [BASE]
Creates release branch from 'develop'. Optionally specify [BASE] commit SHA-1.
Publish release:
git flow release publish RELEASE
Track remote release:
git flow release track RELEASE
Finish release:
git flow release finish RELEASE
This will:
- Merge release branch into 'master'
- Tag the release
- Back-merge release into 'develop'
- Remove release branch
ð¡ Don't forget: Push your tags with
git push --tags
ð¥ Hotfixes
Hotfixes address critical issues in live production versions. They branch off from the corresponding tag on master.
Start hotfix:
git flow hotfix start VERSION [BASENAME]
Finish hotfix:
git flow hotfix finish VERSION
Merges back into both 'develop' and 'master', and tags the master merge
ð Commands Overview
ð Git Flow Schema
ð Other Languages
This cheat sheet is available in multiple languages:
Language | Link |
---|---|
ð¸ð¦ Arabic | git-cheat-sheet-ar.md |
ð§ð© Bengali | git-cheat-sheet-bn.md |
ð§ð· Brazilian Portuguese | git-cheat-sheet-pt_BR.md |
ð¨ð³ Chinese | git-cheat-sheet-zh.md |
ð©ðª German | git-cheat-sheet-de.md |
ð¬ð· Greek | git-cheat-sheet-el.md |
ð®ð³ Hindi | git-cheat-sheet-hi.md |
ð°ð· Korean | git-cheat-sheet-ko.md |
ðµð± Polish | git-cheat-sheet-pl.md |
ðªð¸ Spanish | git-cheat-sheet-es.md |
ð¹ð· Turkish | git-cheat-sheet-tr.md |
ð¤ Contributing
We welcome contributions! You can:
- ð Report bugs or typos
- ⨠Add new Git commands
- ð Translate to new languages
- ð¡ Improve explanations
- ð Enhance formatting
How to contribute:
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
ð License
This project is open source and available under the MIT License.
â Star this repository if you found it helpful!
Top Related Projects
A list of cool features of Git and GitHub.
Most commonly used git tips and tricks.
Flight rules for git
git - the simple guide
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot