{"id":21079327,"url":"https://github.com/sahil-popat-potale/git-cheat-sheet","last_synced_at":"2026-04-17T00:02:09.149Z","repository":{"id":254599904,"uuid":"846998982","full_name":"Sahil-Popat-Potale/Git-Cheat-Sheet","owner":"Sahil-Popat-Potale","description":"A concise and comprehensive Git cheat sheet to help you quickly reference and use the most common and help full Git commands. This cheat sheet is perfect for beginners and experienced developers alike, offering clear examples and descriptions of essential Git operations.","archived":false,"fork":false,"pushed_at":"2024-09-08T07:27:28.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-03T03:44:49.789Z","etag":null,"topics":["git-cheatsheet","git-commands","github","github-actions"],"latest_commit_sha":null,"homepage":"","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/Sahil-Popat-Potale.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}},"created_at":"2024-08-24T15:01:40.000Z","updated_at":"2024-11-24T15:43:37.000Z","dependencies_parsed_at":"2024-08-24T17:29:24.803Z","dependency_job_id":"b3545753-7616-4dc2-803e-4f84e6ef31e1","html_url":"https://github.com/Sahil-Popat-Potale/Git-Cheat-Sheet","commit_stats":null,"previous_names":["sahil-popat-potale/git-cheat-sheet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Sahil-Popat-Potale/Git-Cheat-Sheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sahil-Popat-Potale%2FGit-Cheat-Sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sahil-Popat-Potale%2FGit-Cheat-Sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sahil-Popat-Potale%2FGit-Cheat-Sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sahil-Popat-Potale%2FGit-Cheat-Sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sahil-Popat-Potale","download_url":"https://codeload.github.com/Sahil-Popat-Potale/Git-Cheat-Sheet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sahil-Popat-Potale%2FGit-Cheat-Sheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31909235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["git-cheatsheet","git-commands","github","github-actions"],"created_at":"2024-11-19T19:45:44.517Z","updated_at":"2026-04-17T00:02:09.104Z","avatar_url":"https://github.com/Sahil-Popat-Potale.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"---\n\n# 📄 Git Cheat Sheet\n\nA comprehensive and easy-to-use Git cheat sheet to help you quickly reference the most common Git commands. Each command is accompanied by a brief description and an example, making it perfect for both beginners and experienced developers.\n\n---\n\n## 🛠️ Git Configuration\n\n### **Set Global Username and Email**\n```bash\ngit config --global user.name \"Your Name\"\ngit config --global user.email \"your.email@example.com\"\n```\n\n### **List All Configurations**\n```bash\ngit config --list\n```\n\n---\n\n## 📂 Repository Setup\n\n### **Initialize a New Repository**\n```bash\ngit init\n```\n\n### **Clone an Existing Repository**\n```bash\ngit clone https://github.com/username/repository.git\n```\n\n---\n\n## 🔄 Basic Workflow\n\n### **Check the Status of Your Repository**\n```bash\ngit status\n```\n\n### **Add Files to the Staging Area**\n```bash\n# Add a specific file\ngit add filename.txt\n\n# Add all changes\ngit add .\n```\n\n### **Commit Changes**\n```bash\ngit commit -m \"Your commit message\"\n```\n\n### **Push Changes to the Remote Repository**\n```bash\ngit push origin main\n```\n\n### **Pull Changes from the Remote Repository**\n```bash\ngit pull origin main\n```\n\n---\n\n## 🌳 Branching\n\n### **List All Branches**\n```bash\ngit branch\n```\n\n### **Create a New Branch**\n```bash\ngit branch new-branch\n```\n\n### **Switch to a Branch**\n```bash\ngit checkout branch-name\n```\n\n### **Create and Switch to a New Branch**\n```bash\ngit checkout -b new-branch\n```\n\n### **Merge a Branch into the Current Branch**\n```bash\ngit merge branch-name\n```\n\n### **Delete a Branch**\n```bash\ngit branch -d branch-name\n```\n\n---\n\n## 🌐 Remote Repositories\n\n### **Add a Remote Repository**\n```bash\ngit remote add origin https://github.com/username/repository.git\n```\n\n### **View All Remote Repositories**\n```bash\ngit remote -v\n```\n\n### **Remove a Remote Repository**\n```bash\ngit remote remove origin\n```\n\n---\n\n## 🕒 Logs and History\n\n### **View the Commit History**\n```bash\ngit log\n```\n\n### **View a Simplified Commit History**\n```bash\ngit log --oneline\n```\n\n### **Show Differences Between Commits or Branches**\n```bash\n# Show differences between working directory and staging area\ngit diff\n\n# Show differences between two branches\ngit diff branch1 branch2\n```\n\n---\n\n## 💾 Stashing\n\n### **Stash Changes**\n```bash\ngit stash\n```\n\n### **Apply Stashed Changes**\n```bash\ngit stash apply\n```\n\n### **List All Stashes**\n```bash\ngit stash list\n```\n\n### **Drop a Stash**\n```bash\ngit stash drop\n```\n\n---\n\n## 🔄 Undoing Changes\n\n### **Unstage a File**\n```bash\ngit reset HEAD filename.txt\n```\n\n### **Undo a Commit and Keep Changes**\n```bash\ngit reset --soft commit_hash\n```\n\n### **Undo a Commit and Remove Changes**\n```bash\ngit reset --hard commit_hash\n```\n\n### **Restore a Specific File**\n```bash\ngit checkout -- filename.txt\n```\n\n---\n\n## 🗑️ Removing Files\n\n### **Remove a File and Stage the Deletion**\n```bash\ngit rm filename.txt\n```\n\n### **Remove a File from Staging but Keep It Locally**\n```bash\ngit rm --cached filename.txt\n```\n\n---\n\n## 🏷️ Tagging\n\n### **Create a Lightweight Tag**\n```bash\ngit tag tag-name\n```\n\n### **Create an Annotated Tag**\n```bash\ngit tag -a tag-name -m \"Tag message\"\n```\n\n### **Push Tags to the Remote Repository**\n```bash\ngit push origin tag-name\n```\n\n---\n\n## 🔄 Fetching and Rebasing\n\n### **Fetch Changes from a Remote Repository**\n```bash\ngit fetch origin\n```\n\n### **Reapply Commits on Top of Another Base Tip**\n```bash\ngit rebase branch-name\n```\n\n### **Abort a Rebase in Progress**\n```bash\ngit rebase --abort\n```\n\n\nHere are the remaining Git commands organized into proper categories and formatted to continue from the previous cheat sheet:\n\n---\n\n## 🖼️ Tagging and Version Control\n\n### **Delete a Tag**\n```bash\ngit tag -d tag-name\n```\n**How it works**: This command deletes a tag locally from your repository. The tag will still exist on the remote until you delete it there as well.\n\n### **Push All Tags to the Remote Repository**\n```bash\ngit push origin --tags\n```\n**How it works**: The `git push --tags` command pushes all local tags to the remote repository, making them available to everyone.\n\n### **Delete a Tag from the Remote Repository**\n```bash\ngit push origin --delete tag tag-name\n```\n**How it works**: This command removes a tag from the remote repository so that it is no longer available to others.\n\n---\n\n## 🧹 Cleaning Up\n\n### **Remove Untracked Files**\n```bash\ngit clean -f\n```\n**How it works**: The `git clean` command removes untracked files from the working directory, helping you clean up unnecessary files. Use `-f` to force the deletion.\n\n### **Dry Run to See What Would Be Removed**\n```bash\ngit clean -n\n```\n**How it works**: This command performs a dry run, showing you which untracked files would be deleted without actually deleting them.\n\n---\n\n## 🔀 Rewriting History\n\n### **Amend the Last Commit**\n```bash\ngit commit --amend -m \"Updated commit message\"\n```\n**How it works**: The `git commit --amend` command allows you to modify the most recent commit. You can change the commit message or add new changes.\n\n### **Rebase Interactively**\n```bash\ngit rebase -i commit_hash\n```\n**How it works**: This command opens an interactive rebase session, where you can modify, combine, or delete previous commits.\n\n---\n\n## 🕹️ Cherry-Picking\n\n### **Apply a Specific Commit to the Current Branch**\n```bash\ngit cherry-pick commit_hash\n```\n**How it works**: The `git cherry-pick` command allows you to apply changes from a specific commit on one branch to another branch.\n\n---\n\n## 🚨 Conflict Resolution\n\n### **Show Conflicts After a Merge**\n```bash\ngit status\n```\n**How it works**: After a merge conflict, running `git status` will show the files that have conflicts. You can then manually resolve them.\n\n### **Mark Conflicts as Resolved**\n```bash\ngit add filename.txt\n```\n**How it works**: After resolving conflicts in a file, add the file to the staging area with `git add` to mark it as resolved.\n\n### **Continue After Resolving Conflicts**\n```bash\ngit merge --continue\n```\n**How it works**: This command continues the merge process after you've resolved any conflicts.\n\n### **Abort a Merge**\n```bash\ngit merge --abort\n```\n**How it works**: This command aborts a merge in progress and returns the repository to its previous state before the merge started.\n\n---\n\n## ⚙️ Advanced Workflows\n\n### **Squash Commits**\n```bash\ngit rebase -i HEAD~n\n```\n**How it works**: The `git rebase -i` command lets you combine several commits into one. Replace `n` with the number of commits you'd like to squash.\n\n### **Bisect to Find Buggy Commits**\n```bash\ngit bisect start\ngit bisect bad\ngit bisect good commit_hash\n```\n**How it works**: The `git bisect` command performs a binary search to find which commit introduced a bug. Mark the bad and good commits, and Git will help you locate the culprit.\n\n---\n\n## 🔒 Security and Maintenance\n\n### **Sign a Commit**\n```bash\ngit commit -S -m \"Signed commit message\"\n```\n**How it works**: This command signs your commits with a GPG key, ensuring their authenticity and integrity.\n\n### **Verify Signed Commits**\n```bash\ngit log --show-signature\n```\n**How it works**: This command checks the signatures of past commits, confirming whether they were signed and valid.\n\n---\n\n## 📊 Git Aliases\n\n### **Create a Git Alias**\n```bash\ngit config --global alias.co checkout\n```\n**How it works**: The `git config` command lets you create shortcuts for frequently used Git commands. Here, `git co` becomes shorthand for `git checkout`.\n\n### **List All Aliases**\n```bash\ngit config --get-regexp alias\n```\n**How it works**: This command lists all your Git aliases, showing you the shortcuts you've set up for quicker workflows.\n\n---\n\n## 🗂️ Submodules\n\n### **Add a Submodule**\n```bash\ngit submodule add https://github.com/username/repository.git\n```\n**How it works**: The `git submodule add` command includes another Git repository as a submodule within your project, allowing you to track it as a separate module.\n\n### **Initialize Submodules**\n```bash\ngit submodule init\n```\n**How it works**: This command initializes all submodules in your project after they have been cloned.\n\n### **Update Submodules**\n```bash\ngit submodule update\n```\n**How it works**: The `git submodule update` command updates all submodules to their latest commits, ensuring they are in sync with the parent project.\n\n---\n\n## 🏗️ Hooks\n\n### **Create a Pre-Commit Hook**\n```bash\n# Navigate to .git/hooks/ directory\ncd .git/hooks/\n\n# Create a new pre-commit hook\ntouch pre-commit\n```\n**How it works**: This command creates a pre-commit hook script in the `.git/hooks/` directory. Pre-commit hooks run before each commit to check code quality or perform other tasks.\n\n---\n\n## 🎯 Conclusion\n\nThis Git cheat sheet covers the essential commands you'll need for most workflows. Keep it handy as a quick reference guide, and enhance your Git skills with ease! If you need more advanced commands or explanations, don't hesitate to dive deeper into the Git documentation or explore additional resources.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsahil-popat-potale%2Fgit-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsahil-popat-potale%2Fgit-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsahil-popat-potale%2Fgit-cheat-sheet/lists"}