{"id":22650679,"url":"https://github.com/kausalyanp/git_cheat_sheet","last_synced_at":"2026-05-06T11:36:50.293Z","repository":{"id":265894333,"uuid":"896811083","full_name":"kausalyanp/Git_Cheat_sheet","owner":"kausalyanp","description":"It contains all commonly and uncommonly used gitcommands with explanation.","archived":false,"fork":false,"pushed_at":"2024-12-02T07:43:12.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T20:50:29.338Z","etag":null,"topics":["cheat","cheat-sheet","cheat-sheets","cheats","cheatsheet","cheatsheets","git","github","github-actions","github-api","github-cloud-migrated","github-config","github-pages","githugged","gitops"],"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/kausalyanp.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-12-01T11:22:49.000Z","updated_at":"2024-12-02T07:43:15.000Z","dependencies_parsed_at":"2025-02-03T20:48:48.347Z","dependency_job_id":"f3080711-d545-4bf5-831b-87e17661906f","html_url":"https://github.com/kausalyanp/Git_Cheat_sheet","commit_stats":null,"previous_names":["kausalyanp/git_cheat_sheet"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kausalyanp%2FGit_Cheat_sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kausalyanp%2FGit_Cheat_sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kausalyanp%2FGit_Cheat_sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kausalyanp%2FGit_Cheat_sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kausalyanp","download_url":"https://codeload.github.com/kausalyanp/Git_Cheat_sheet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246151581,"owners_count":20731631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cheat","cheat-sheet","cheat-sheets","cheats","cheatsheet","cheatsheets","git","github","github-actions","github-api","github-cloud-migrated","github-config","github-pages","githugged","gitops"],"created_at":"2024-12-09T08:36:40.280Z","updated_at":"2025-10-14T12:06:08.281Z","avatar_url":"https://github.com/kausalyanp.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Cheat Sheet\nIt contains all commonly and uncommonly used git commands with explanation.\n\n\u003ca name=\"top\"\u003e\u003c/a\u003e\n\nTable of Contents:\n1. [Setup and Configuration](#1-setup-and-configuration)\n2. [Creating and Initializing Repositories](#2-creating-and-initializing-repositories)\n3. [Staging and Committing Changes](#3-staging-and-committing-changes)\n4. [Viewing Changes and Logs](#4-viewing-changes-and-logs)\n5. [Branching and Merging](#5-branching-and-merging)\n6. [Remote Repositories](#6-remote-repositories)\n7. [Tagging](#7-tagging)\n8. [Undoing Changes](#8-undoing-changes)\n9. [Stashing Changes](#9-stashing-changes)\n10. [Advanced Operations](#10-advanced-operations)\n11. [Collaboration and Contributing](#11-collaboration-and-contributing)\n\n## 1. Setup and Configuration:\n1. Sets the username for all repositories on your machine.\n```\ngit config --global user.name \"Your Name\"\n```\n2. Sets the email for all repositories on your machine.\n```\ngit config --global user.email \"you@example.com\"\n```\n3. Displays all configuration settings.\n```\ngit config --list\n```\n4. Sets the default text editor for Git (e.g., vim, nano).\n```\ngit config --global core.editor \u003ceditor\u003e\n```\n5. Creates a shortcut for a Git command.\n```\ngit config --global alias.\u003calias-name\u003e \u003ccommand\u003e\n```\n[Back to Top](#top)\n\n## 2. Creating and Initializing Repositories\n1. Initializes a new Git repository in the current directory.\n```\ngit init\t\n```\n2. Creates a local copy of a remote repository.\n```\ngit clone \u003crepository-url\u003e\n```\n[Back to Top](#top)\n\n## 3. Staging and Committing Changes\n1. Adds a file to the staging area.\n```\ngit add \u003cfile\u003e\n```\n2. Adds all changes in the current directory to the staging area.\n```\ngit add .\n```\n3. Creates a commit with the specified message.\n```\ngit commit -m \"Commit message\"\n```\n4. Stages and commits all tracked files in one step.\n```\ngit commit -a -m \"Commit message\"\n```\n5. Unstages a file from the staging area.\n```\ngit restore --staged \u003cfile\u003e\n```\n[Back to Top](#top)\n\n## 4. Viewing Changes and Logs\n1.  Displays the status of files in the working directory and staging area.\n```\ngit status\n```\n2. Shows differences between the working directory and the staging area.\n```\ngit diff\n```\n3. Shows differences between the staging area and the last commit.\n```\ngit diff --staged\n```\n4. Displays a history of commits.\n```\ngit log\n```\n5. Shows a condensed commit history.\n```\ngit log --oneline\n```\n6. Displays details of a specific commit.\n```\ngit show \u003ccommit-hash\u003e\n```\n[Back to Top](#top)\n\n## 5. Branching and Merging\n1. Lists all branches in the repository.\n```\ngit branch\n```\n2. Creates a new branch.\n```\ngit branch \u003cbranch-name\u003e\n```\n3. Switches to the specified branch.\n```\ngit checkout \u003cbranch-name\u003e\n```\n4. Another way to switch branches.\n```\ngit switch \u003cbranch-name\u003e\n```\n5. Creates and switches to a new branch.\n```\ngit checkout -b \u003cbranch-name\u003e\n```\n6. Merges the specified branch into the current branch.\n```\ngit merge \u003cbranch-name\u003e\n```\n7. Deletes the specified branch.\n```\ngit branch -d \u003cbranch-name\u003e\n```\n[Back to Top](#top)\n\n## 6. Remote Repositories\n1. Links a local repository to a remote repository.\n```\ngit remote add origin \u003curl\u003e\t\n```\n2. Lists remote connections.\n```\ngit remote -v\n```\n3. Pushes commits from the local branch to the remote branch.\n```\ngit push origin \u003cbranch-name\u003e\n```\n4. Fetches changes from the remote repository without merging them.\n```\ngit fetch\n```\n5. Fetches and merges changes from the remote repository.\n```\ngit pull\n```\n6. Pushes a new branch and sets it to track the remote branch.\n```\ngit push --set-upstream origin \u003cbranch-name\u003e\n```\n[Back to Top](#top)\n\n## 7. Tagging\n1. Creates a lightweight tag for the current commit.\n```\ngit tag \u003ctag-name\u003e\n```\n2. Creates an annotated tag.\n```\ngit tag -a \u003ctag-name\u003e -m \"Message\"\n```\n3. Displays details about a tag.\n```\ngit show \u003ctag-name\u003e\n```\n4. Pushes a tag to the remote repository.\n```\ngit push origin \u003ctag-name\u003e\n```\n5. Pushes all tags to the remote repository.\n```\ngit push --tags\n```\n[Back to Top](#top)\n\n## 8. Undoing Changes\n1. Restores a file to its last committed state.\n```\ngit restore \u003cfile\u003e\t\n```\n2. Resets the current branch to the specified commit.\n```\ngit reset \u003ccommit\u003e\n```\n3. Resets to the commit but keeps changes staged.\n```\ngit reset --soft \u003ccommit\u003e\n```\n4. Resets to the commit and removes all changes.\n```\ngit reset --hard \u003ccommit\u003e\n```\n5. Creates a new commit that undoes the changes from a specific commit.\n```\ngit revert \u003ccommit\u003e\n```\n[Back to Top](#top)\n\n## 9. Stashing Changes\n1. Temporarily saves changes without committing them.\n```\ngit stash\n```\n2. Lists all stashes.\n```\ngit stash list\n```\n3. Applies a specific stash.\n```\ngit stash apply \u003cstash\u003e\n```\n4. Applies and removes the most recent stash.\n```\ngit stash pop\n```\n5. Deletes a specific stash.\n```\ngit stash drop \u003cstash\u003e\n```\n[Back to Top](#top)\n\n## 10. Advanced Operations\n1. Applies a specific commit to the current branch.\n```\ngit cherry-pick \u003ccommit\u003e\n```\n2. Moves the base of the current branch to the specified branch.\n```\ngit rebase \u003cbranch-name\u003e\n```\n3. Displays a log of all reference updates (useful for recovery).\n```\ngit reflog\n```\n4. Helps identify the commit that introduced a bug.\n```\ngit bisect\n```\n[Back to Top](#top)\n\n## 11. Collaboration and Contributing\n1. Creates a personal copy of a repository on GitHub or similar platforms.\n```\ngit fork\n```\n2. Fetches changes from the original repository of a fork.\n```\ngit fetch upstream\n```\n3. Replays local commits on top of the upstream branch.\n```\ngit rebase upstream/\u003cbranch\u003e\n```\n[Back to Top](#top)\n\n###\nCreated By Kausalya N P\n\u003e\u003e Users can copy this repo for educational purpose.\n###\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkausalyanp%2Fgit_cheat_sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkausalyanp%2Fgit_cheat_sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkausalyanp%2Fgit_cheat_sheet/lists"}