{"id":26241462,"url":"https://github.com/samarth4023/git-cheat-sheet","last_synced_at":"2026-04-02T02:06:12.259Z","repository":{"id":275780687,"uuid":"927171180","full_name":"Samarth4023/Git-Cheat-Sheet","owner":"Samarth4023","description":"📜 Git Cheat Sheet - All Commands in One Place This repository contains a comprehensive Git cheat sheet with all existing Git commands compiled into a single README file. Perfect for quick reference and mastering Git workflows! 🚀","archived":false,"fork":false,"pushed_at":"2025-02-04T15:33:04.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T02:35:49.152Z","etag":null,"topics":["cheatsheet","cheatsheets","git","gitcommands","github"],"latest_commit_sha":null,"homepage":"https://github.com/Samarth4023/Git-Cheat-Sheet.git","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Samarth4023.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-04T14:23:46.000Z","updated_at":"2025-03-24T10:09:29.000Z","dependencies_parsed_at":"2025-02-04T15:29:35.734Z","dependency_job_id":"eda4a72b-71eb-4b82-8463-674f3c94926d","html_url":"https://github.com/Samarth4023/Git-Cheat-Sheet","commit_stats":null,"previous_names":["samarth4023/git-cheat-sheet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Samarth4023/Git-Cheat-Sheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarth4023%2FGit-Cheat-Sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarth4023%2FGit-Cheat-Sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarth4023%2FGit-Cheat-Sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarth4023%2FGit-Cheat-Sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Samarth4023","download_url":"https://codeload.github.com/Samarth4023/Git-Cheat-Sheet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarth4023%2FGit-Cheat-Sheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","cheatsheets","git","gitcommands","github"],"created_at":"2025-03-13T08:30:16.425Z","updated_at":"2026-04-02T02:06:12.237Z","avatar_url":"https://github.com/Samarth4023.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# **📝 Git Cheat Sheet: The Ultimate Guide**  \n_Last Updated: 2025_\n\n## **📌 Basic Configuration**\n```sh\ngit config --global user.name \"Your Name\"                # Set user name\ngit config --global user.email \"you@example.com\"         # Set email\ngit config --global color.ui auto                        # Enable colored output\ngit config --global core.editor nano                     # Set default editor\ngit config --global core.autocrlf true                   # Auto handle line endings\ngit config --list                                        # List all configuration\n```\n\n---\n\n## **📁 Repository Setup**\n```sh\ngit init                        # Initialize a new repository\ngit clone \u003crepo_url\u003e            # Clone an existing repository\ngit remote add origin \u003curl\u003e     # Add remote repository\ngit remote add \u003cname\u003e \u003curl\u003e     # Add a new remote repository\ngit remote -v                   # View remote repositories\ngit remote remove \u003cname\u003e        # Remove remote repository\ngit remote show \u003cname\u003e          # Show information about a remote\n```\n\n---\n\n## **📌 Basic Operations**\n```sh\ngit status                      # Check repository status\ngit add \u003cfile\u003e                  # Stage a specific file\ngit add .                       # Stage all files\ngit commit -m \"Message\"         # Commit changes\ngit commit -am \"Message\"        # Add \u0026 commit in one step\ngit log                         # View commit history\ngit log --oneline               # Compact log\ngit log --graph --decorate      # Log with branches visualization\n```\n\n---\n\n## **🔄 Branching \u0026 Merging**\n```sh\ngit branch                      # List branches\ngit branch \u003cbranch_name\u003e        # Create new branch\ngit checkout \u003cbranch_name\u003e      # Switch to branch\ngit checkout -b \u003cbranch_name\u003e   # Create \u0026 switch branch\ngit merge \u003cbranch_name\u003e         # Merge branch into current\ngit branch -d \u003cbranch_name\u003e     # Delete branch\ngit branch -D \u003cbranch_name\u003e     # Force delete branch\ngit branch --show-current       # Show current branch\n```\n\n---\n\n## **⏪ Undo Changes**\n```sh\ngit checkout -- \u003cfile\u003e          # Discard changes in working directory\ngit restore \u003cfile\u003e              # Alternative to checkout (Git v2.23+)\ngit reset HEAD \u003cfile\u003e           # Unstage file (keep changes)\ngit reset --hard                # Reset all changes (CAUTION)\ngit revert \u003ccommit\u003e             # Create a new commit that undoes a previous one\n```\n\n---\n\n## **🚀 Pushing \u0026 Pulling**\n```sh\ngit push origin \u003cbranch\u003e        # Push to remote branch\ngit push \u003cremote\u003e \u003cbranch\u003e      # Push changes to a remote repository\ngit push -u origin \u003cbranch\u003e     # Push and track upstream\ngit push --force                # Force push (use with caution)\ngit pull origin \u003cbranch\u003e        # Pull latest changes\ngit pull --rebase               # Pull and rebase instead of merging\ngit fetch                       # Fetch changes without merging\ngit fetch \u003cremote\u003e              # Fetch changes from a remote repository\ngit fetch --prune               # Fetch and remove deleted remote branches\n```\n\n---\n\n## **🛠️ Low-Level Internal Commands (Plumbing)**\nThese are the deep internal commands that Git uses under the hood.\n```sh\ngit apply                     # Apply a patch to files\ngit cat-file                  # Show object contents (blob, commit, tag, tree)\ngit check-ignore              # Show files ignored by .gitignore\ngit check-attr                # Show attributes of files\ngit cherry                    # Find commits that exist in one branch but not another\ngit commit-tree               # Create a commit object manually\ngit count-objects             # Count the number of objects in the database\ngit diff-index                # Compare index with another tree or commit\ngit for-each-ref              # Show all references in repository\ngit hash-object               # Compute SHA-1 hash of a file\ngit index-pack                # Build pack index file\ngit merge-base                # Find common ancestor of two commits\ngit mktag                     # Create a tag object manually\ngit mktree                    # Create a tree object manually\ngit pack-objects              # Create a packed object file\ngit prune                     # Remove unreachable objects\ngit read-tree                 # Read tree information into index\ngit rev-list                  # Show list of commits reachable from a reference\ngit rev-parse                 # Parse and convert revision names\ngit symbolic-ref              # Read, change, or delete symbolic refs\ngit unpack-objects            # Unpack objects from a pack file\ngit update-index              # Manage Git index manually\ngit verify-pack               # Validate packed Git objects\ngit write-tree                # Create a tree object from current index\n```\n\n---\n\n## **🕵️‍♂️ Stashing**\n```sh\ngit stash                       # Save current work temporarily\ngit stash list                  # Show stashed changes\ngit stash apply                 # Apply last stashed change\ngit stash pop                   # Apply and remove from stash\ngit stash drop                  # Delete last stash\ngit stash clear                 # Delete all stashes\n```\n\n---\n\n## **🔄 Rebasing**\n```sh\ngit rebase \u003cbranch\u003e             # Rebase onto another branch\ngit rebase -i HEAD~3            # Interactive rebase last 3 commits\ngit rebase --abort              # Cancel rebase\ngit rebase --continue           # Continue after resolving conflicts\n```\n\n---\n\n## **🔄 Reset vs. Revert**\n```sh\ngit reset --mixed HEAD~1       # Undo commit (keep changes unstaged)\ngit reset --soft HEAD~1        # Undo last commit (keep changes staged)\ngit reset --hard HEAD~1        # Undo last commit (discard changes)\n```\n\n---\n\n## **🔍 Searching \u0026 Comparing**\n```sh\ngit grep \"pattern\"              # Search for text in repo\ngit diff                        # Show unstaged changes\ngit diff --staged               # Show staged changes\ngit diff \u003cbranch1\u003e..\u003cbranch2\u003e   # Compare two branches\ngit blame \u003cfile\u003e                # Show who changed what line\n```\n\n---\n\n## **🔄 Tagging**\n```sh\ngit tag                                  # List all tags\ngit tag \u003ctagname\u003e                        # Create a new tag\ngit tag -a \u003ctagname\u003e -m \"msg\"            # Create annotated tag\ngit push origin \u003ctagname\u003e                # Push a tag\ngit push --tags                          # Push all tags\ngit tag -d \u003ctagname\u003e                     # Delete local tag\ngit push origin --delete \u003ctagname\u003e       # Delete remote tag\n```\n\n---\n\n## **💣 Deleting \u0026 Cleaning**\n```sh\ngit rm \u003cfile\u003e                   # Remove file from repo \u0026 working dir\ngit rm --cached \u003cfile\u003e          # Remove from repo but keep locally\ngit mv                          # Move or rename a file\ngit clean -f                    # Remove untracked files\ngit clean -fd                   # Remove untracked files \u0026 directories\n```\n\n---\n\n## **⏳ Working with Commits**\n```sh\ngit commit --amend -m \"New message\"  # Change last commit message\ngit cherry-pick \u003ccommit_hash\u003e        # Apply specific commit from another branch\ngit reflog                           # Show history of HEAD changes\n```\n\n---\n\n## **👥 Collaborating**\n```sh\ngit pull --rebase origin main        # Pull with rebase\ngit push origin \u003cbranch\u003e --force     # Force push (use cautiously)\ngit merge --no-ff \u003cbranch\u003e           # Merge without fast-forward\ngit merge --squash \u003cbranch\u003e          # Merge but keep commits as one\n```\n\n---\n\n## **🔐 Managing Credentials**\n```sh\ngit credential-cache exit                      # Clear cached credentials\ngit credential reject https://github.com\ngit credential approve https://github.com\n```\n\n---\n\n## **🌎 Working with Submodules**\n```sh\ngit submodule add \u003crepo_url\u003e                    # Add submodule\ngit submodule update --init --recursive         # Clone/update submodules\ngit submodule foreach git pull origin main      # Update all submodules\ngit submodule deinit -f --all                   # Remove all submodules\n```\n\n---\n\n## **🧪 Advanced Git Features**\n```sh\ngit show \u003ccommit\u003e              # Show details of a specific commit\ngit shortlog                   # Summarize commit history by author\ngit whatchanged                # Show file changes with commit history\ngit archive                    # Create an archive from a repository\ngit describe                   # Describe commits in a readable format\ngit log --graph --oneline      # Show commits in a compact graph\ngit bisect start               # Start binary search for bugs\ngit bisect bad                 # Mark current commit as bad\ngit bisect good \u003ccommit\u003e       # Mark commit as good\ngit bisect reset               # End bisect session\n```\n\n---\n\n## **📦 Working with Large Files**\n```sh\ngit lfs install                                             # Install Git LFS\ngit lfs track \"*.zip\"                                       # Track large files\ngit add .gitattributes                                      # Add LFS config\ngit lfs migrate import --everything --include=\"*.zip\"       # Migrate existing files\n```\n\n---\n\n## **🛠️ Git Maintenance \u0026 Cleanup**\n```sh\ngit fsck                      # Check repository integrity\ngit gc                        # Cleanup unnecessary files\ngit prune                     # Remove unreachable objects\ngit repack                    # Pack objects to optimize space\ngit verify-commit \u003ccommit\u003e    # Check commit validity\ngit verify-tag \u003ctag\u003e          # Check tag validity\n```\n\n---\n\n## **🐳 Working with Aliases**\n```sh\ngit config --global alias.co checkout\ngit config --global alias.br branch\ngit config --global alias.st status\ngit config --global alias.unstage \"reset HEAD --\"\ngit config --global alias.last \"log -1 HEAD\"\n```\n\n---\n\n## **📊 Viewing Statistics**\n```sh\ngit shortlog -sn                       # Show commits per author\ngit diff --stat                        # Show file changes summary\ngit count-objects -v                   # Count objects in repository\n```\n\n---\n\n## **⚡ Git Worktree (Multiple Workspaces)**\n```sh\ngit worktree add \u003cpath\u003e \u003cbranch\u003e     # Create a new working tree\ngit worktree list                    # List all worktrees\ngit worktree remove \u003cpath\u003e           # Remove a worktree\n```\n\n---\n\n## **🔥 How to See ALL Available Commands in Your Git Version**\n```sh\ngit help -a                    # List all available Git commands\ngit help -g                    # Grouped command list\ngit help -a | grep '  '        # Plumbing \u0026 Porcelain\ngit \u003ccommand\u003e --help           # Detailed help for a specific command\n```\n- Plumbing Commands: Low-level commands used internally by Git.\n- Porcelain Commands: High-level user-friendly commands.\n  \n---\n\nThis cheat sheet includes **almost all** Git commands that exist!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamarth4023%2Fgit-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamarth4023%2Fgit-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamarth4023%2Fgit-cheat-sheet/lists"}