{"id":24014892,"url":"https://github.com/hazrat16/git-cheat-sheet","last_synced_at":"2025-10-12T10:12:59.739Z","repository":{"id":242209052,"uuid":"808937265","full_name":"Hazrat16/git-cheat-sheet","owner":"Hazrat16","description":"Compilation of essential Git commands which you will be using frequently while you are working with Git. ","archived":false,"fork":false,"pushed_at":"2024-06-01T18:01:02.000Z","size":1044,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T10:12:58.955Z","etag":null,"topics":["git","git-cheatsheet"],"latest_commit_sha":null,"homepage":"https://hazrat16.github.io/git-cheat-sheet/","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/Hazrat16.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-06-01T07:59:33.000Z","updated_at":"2024-06-01T18:13:14.000Z","dependencies_parsed_at":"2024-06-01T20:19:10.706Z","dependency_job_id":null,"html_url":"https://github.com/Hazrat16/git-cheat-sheet","commit_stats":null,"previous_names":["hazrat16/git-commands","hazrat16/git-cheat-sheet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Hazrat16/git-cheat-sheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazrat16%2Fgit-cheat-sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazrat16%2Fgit-cheat-sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazrat16%2Fgit-cheat-sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazrat16%2Fgit-cheat-sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hazrat16","download_url":"https://codeload.github.com/Hazrat16/git-cheat-sheet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazrat16%2Fgit-cheat-sheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279011052,"owners_count":26084863,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"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":["git","git-cheatsheet"],"created_at":"2025-01-08T07:37:52.760Z","updated_at":"2025-10-12T10:12:59.724Z","avatar_url":"https://github.com/Hazrat16.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e Git Commands Scribe Sheet \u003c/h1\u003e\n\n\u003cdiv style=\"text-align:center;\"\u003e\n\u003cimg src=\"./screenshots/git.png\" /\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\u003ci\u003eby \u003ca href=\"https://github.com/Hazrat16\"\u003eS.M. Hazrat Ali \u003c/a\u003e\u003c/i\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eHere's a comprehensive scribe sheet for frequently used Git commands in professional settings, complete with descriptions, examples, and screenshots. \u003c/p\u003e\n\n### Table of Contents :\n\n1. [Git Setup and Configuration](#git-setup-and-configuration)\n\n   - [Git Setup](#git-setup)\n   - [Git Version](#git-version)\n   - [Git Config](#git-config)\n   - [Git Alias](#git-alias)\n   - [Git SSH Keys Setup](#git-ssh-keys-setup)\n\n2. [Staging \u0026 Committing](#staging-\u0026-committing)\n\n   - [Git Init](#git-init)\n   - [Git Clone](#git-clone)\n   - [Git Status](#git-status)\n   - [Git Add](#git-add)\n   - [Git Commit](#git-commit)\n   - [Git Stash](#git-stash)\n   - [Git Restore](#git-restore)\n\n3. [Inspection and Comparison](#inspection-and-comparison)\n\n   - [Git Log](#git-log)\n   - [Git Relog](#git-relog)\n   - [Git Diff](#git-reset)\n   - [Git Show](#git-show)\n\n4. [Branching and Merging](#branching-and-merging)\n\n   - [Git Branch](#git-branch)\n   - [Git Checkout](#git-checkout)\n   - [Git Merge](#git-merge)\n   - [Git Rebase](#git-rebase)\n\n5. [Collaboration](#collaboration)\n\n   - [Git Remote](#git-remote)\n   - [Git Push](#git-push)\n   - [Git Fetch](#git-fetch)\n   - [Git Pull](#git-pull)\n\n6. [Git Undoing changes](#git-undoing-changes)\n\n   - [Git Reset](#git-reset)\n   - [Git Revert](#git-revert)\n   - [Git Rm](#git-rm)\n   - [Git Amend](#git-amend)\n   - [Git Cherry Pick](#git-cherry-pick)\n\n7. [Git Tagging](#git-tagging)\n8. [Git Cleanup](#git-cleanup)\n9. [Git Ignore Files](#git-ignore-files)\n10. [Git Hooks](#git-hooks)\n11. [Git Tips and Tricks](#git-tips-and-tricks)\n12. [Git References](#git-references)\n\n# Git Setup and Configuration :\n\n## Git Setup:\n\nInstall Git on your system.\n\n##### 1. Windows:\n\n- Download Git from the [official Git website](https://git-scm.com/download/win).\n\n##### 2. Linux:\n\n**For Debian-based distributions (e.g., Ubuntu):**\nGit is likely already installed in Linux distributions. You can confirm this is the case on your server with the following command:\n`git --version`\n\n1. Update the package list:\n\n```bash\n   sudo apt update\n```\n\n2. Install Git:\n\n```bash\n   sudo apt install git\n```\n\n##### 3. macOS:\n\nInstall Homebrew if you haven't already:\n\n```bash\n   /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"\n```\n\n## Git Version\n\nDisplays the currently installed version of Git.\n\n- This command checks if Git is installed on your system. If Git is not installed, it will install it for you.\n  **Example**\n\n```bash\n   git --version\n```\n\n![Git Version](./screenshots/git-version.png)\n\n**Description :**\nDisplays the current version of Git installed on your system. This command is useful for verifying that Git is installed and for checking the installed version to ensure compatibility with other tools or repositories.\n\n## Git Config\n\nGit config command is a convenience function that is used to set Git configuration values on a global or local project level.\n\n**Description :**\nThe git config command allows you to get and set configuration options that control the appearance and behavior of Git. Configurations can be set at three levels:\n\n- System: Applies to every user on the system and all their repositories.\n- Global: Applies to all repositories for the current user.\n- Local: Applies to the specific repository you are currently working in\n\n![Git Config](./screenshots/git-config.png)\n\n1. **Set User Name**\n   Sets the name that will be attached to your commits and tags.\n   **Example**\n\n```bash\n   // global config for name\n   git config --global user.name \"Hazrat\"\n```\n\n2. **Set User Email**\n   Sets the email address that will be attached to your commits and tags.\n\n```bash\n   // global config email\n   git config --global user.name \"hazrat@email.com\"\n```\n\n## Git Alias\n\nGit aliases are a powerful workflow tool that create shortcuts to frequently used Git commands.\n\n**Example :**\n\n```bash\n   git config --global alias.co checkout\n   git config --global alias.br branch\n```\n\n**Description :**\n\n- Git alias is a mechanism for defining commands that are more accessible and easier to remember than the original command.\n  These aliases make common Git commands shorter and easier to remember. For example:\n\n- `git co` instead of `git checkout`\n- `git br` instead of `git branch`\n- `git ci` instead of `git commit`\n- `git st` instead of `git status`\n\n---\n\n## Git SSH Keys Setup\n\n---\n\n_This Section Optional for GitHub Users Who Want to setup SSH Keys_\n\nSetting up SSH for GitHub involves generating a new SSH key, adding it to your SSH agent, and then adding the public key to your GitHub account\n\n1. Generate a New SSH Key\n\n**Example:**\n\n```bash\n   ssh-keygen -t rsa -b 4096 -C \"hazrat17016@gmail.com\"\n\n```\n\n2. Add Your SSH Key to the SSH Agent\n\n**Example:**\n\n```bash\n   eval \"$(ssh-agent -s)\"\n   ssh-add ~/.ssh/id_rsa\n```\n\n3. Add the Public Key to Your GitHub Account\n\n**Example:**\n\n```bash\n   cat ~/.ssh/id_rsa.pub\n```\n\n4. Test Your SSH Connection\n   You can test your SSH connection to GitHub to ensure everything is set up correctly:\n\n**Example:**\n\n```bash\n   ssh -T git@github.com\n```\n\n\u003c!-- ![Git SSH Keys Setup](./screenshots/git-ssh-keys-setup.png) --\u003e\n\n**Description :**\n\n- SSH keys allow you to securely authenticate Git commands to your repositories. These keys are used to authenticate Git commands when you push changes to your repositories.\n\n[Back to Top](#git-setup)\n\n# Staging \u0026 Committing\n\n## Git Init\n\nInitializes a new Git repository.\n**Example**\n\n```bash\n   git init\n```\n\n![Git Init](./screenshots/git-init.png)\n**Description :**\nInitializes a new Git repository. This command creates a new subdirectory named .git that contains all the necessary repository files.\n\n## Git Status\n\nTo view the current status of the repository:\n**Example**\n\n```bash\n   git status\n```\n\n![Git Status](./screenshots/git-status.png)\n\n- Git Status in Short\n\n**Example**\n\n```bash\n   git status -s\n```\n\n![Git Status](./screenshots/git-status-s.png)\n\n**Description :**\nWhen run git status, Git provides information about:\n\n- Modified files: Files that have been changed but not yet staged for commit.\n- Staged files: Changes that have been added to the staging area and are ready to be committed.\n- Untracked files: Files that are not tracked by Git.\n\n## Git Add\n\nAdds file contents to the staging area.\n**Example**\n\n1. `git add file1.txt`: Adds changes in `file1.txt` to the staging area.\n\n```bash\n   git add file1.txt\n```\n\n2. `git add . `: Adds all changes in the current directory and its subdirectories to the staging area.\n\n```bash\n   git add .\n```\n\n![Git Add](./screenshots/git-add.png)\n\n3.`git add --all` : Adds all changes in the entire working tree to the staging area, including untracked files and removing files that have been deleted.\n\n```bash\n   git add --all\n```\n\n![Git Add](./screenshots/git-add-all.png)\n\n**Description :**\nWhen you make changes to files in your working directory, Git doesn't automatically track those changes. You need to explicitly tell Git which changes you want to include in the next commit using git add.\n\n## Git Commit\n\nThe `git commit` command is used to record changes to the repository.\n**Example**\n\n```bash\n   git commit -m \"commit message\"\n```\n\n![Git Commit](./screenshots/git-commit.png)\n**Description :**\n\n- The -m flag allows you to provide a commit message inline with the command.\n- The commit message should be a brief description of the changes you are committing.\n- After running git commit, Git creates a new commit with the changes staged in the index and records it permanently in the repository's history.\n\n## Git Stash\n\nThe `git stash` command is used to temporarily store changes that are not ready to be committed. It allows you to switch branches or perform other operations without committing incomplete changes.\n\n**Example**\n\n```bash\n   git stash\n```\n\n![Git Stash](./screenshots/git-stash.png)\n\n##### 2. git stash list\n\nLists all the stashed changes. Each stash is given an identifier, which you can use to apply or drop the stash later.\n\n**Example :**\n\n```bash\ngit stash list\n```\n\n![Git Stash](./screenshots/git-stash-list.png)\n\n##### 3. git stash apply\n\nApplies the changes from a specific stash identified by stash_id. If no stash_id is provided, it applies the most recent stash.\n\n**Example :**\n\n```bash\n   git stash apply\n   git stash aplly stash@{2}\n```\n\n![Git Stash](./screenshots/git-stash-apply.png)\n\n##### 4. git stash drop [stash_id]\n\nRemoves a specific stash identified by stash_id from the list of stashes. If no stash_id is provided, it drops the most recent stash.\n\n**Example :**\n\n```bash\n   git stash drop [stash_id]\n```\n\n![Git Stash](./screenshots/git-stash-drop.png)\n\n##### 5. git stash pop\n\nApplies the changes from the most recent stash and removes it from the list of stashes.\n\n**Example :**\n\n```bash\n   git stash pop\n```\n\n![Git Stash](./screenshots/git-stash-pop.png)\n\n##### 6. git stash save\n\nSaves the current state of the working directory and staging area, allowing you to apply or discard changes later.\n\n**Example :**\n\n```bash\n   git stash save\n```\n\n![Git Stash](./screenshots/git-stash-save.png)\n\n##### 7. git stash show [stash_id]\n\nShows the contents of a specific stash identified by stash_id. If no stash_id is provided, it shows the most recent stash.\n\n**Example :**\n\n```bash\n   git stash show [stash_id]\n```\n\n![Git Stash](./screenshots/git-stash-show.png)\n\n##### 8. git stash clear\n\nRemoves all stashes from the list of stashes.\n\n**Example :**\n\n```bash\n   git stash clear\n```\n\n![Git Stash](./screenshots/git-stash-clear.png)\n\n**Description :**\n\n- `git stash` is a handy tool for managing work in progress without committing changes.\n- It saves the current state of the working directory and staging area, allowing you to revert to it later.\n- Stashed changes can be applied or discarded using git stash apply or git stash drop commands.\n- git stash is useful for switching context quickly or temporarily setting aside unfinished work.\n\n# Inspection and Comparison\n\n## Git Log\n\nThe `git log` command is used to view the commit history of a repository. It displays a list of commits in reverse chronological order, showing the commit hash, author, date, and commit message.\n\n**Example**\n\n```bash\ngit log\n```\n\n![Git Log](./screenshots/git-log.png)\n\n**Description :**\n\n- `git log` is a powerful tool for inspecting the history of a repository.\n- It shows the commit history, including the commit hash (SHA-1 checksum), author name, email, date, and commit message.\n- By default, git log displays the commits starting from the most recent.\n\n## Git Reflog\n\nThe `git log` command is used to view the commit history of a repository. It displays a list of commits in reverse chronological order, showing the commit hash, author, date, and commit message.\n\n**Example**\n\n```bash\ngit reflog\n```\n\n![Git Log](./screenshots/git-reflog.png)\n\n**Description :**\n\n-`git reflog` provides insight into the recent actions within a repository, serving as a detailed record of reference updates.\n-It displays information such as commit hashes, descriptions of actions (e.g., commits, merges, resets), timestamps, and reference pointers affected.\n-Unlike `git log`, which focuses on commit history, `git reflog` highlights changes to the repository's references, aiding in debugging, troubleshooting, and recovering lost work.\n\n## Git Show\n\nThe `git show` command is used to view the contents of a commit in the repository. It displays the commit hash, author, date, and commit message.\n\n**Example**\n\n```bash\n   git show\n```\n\n![Git Show](./screenshots/git-show.png)\n**Description :**\n\n- `git show` is a powerful command for viewing the contents of a commit in the repository.\n- It displays the commit hash, author, date, and commit message.\n- `git show` is useful for viewing the changes made in a particular commit.\n\n[Back to Top](#git-setup)\n\n# Branching and Merging\n\n## Git Branch\n\nThe `git branch` command is used to list, create, or delete branches in a Git repository\n\n**Example**\n\n- To list all the local branches in the repository:\n\n```bash\n   git branch\n```\n\n![Git Branch](./screenshots/git-branch.png)\n\n- Creating a Branch\n  To create a new branch in Git, you use the git branch command followed by the name of the new branch you want to create.\n\n```bash\n   git branch branch-1\n```\n\n![Git Branch](./screenshots/git-branch2.png)\n\n- Deleting a Branch\n  To delete a branch in Git, you use the `git branch -d` command followed by the name of the branch you want to delete.\n\n```bash\n   git branch -d branch-1\n```\n\n![Git Branch](./screenshots/git-branch-d.png)\n\n- Checking Out a Branch\n  To switch to a different branch in Git, you use the `git checkout command` followed by the name of the branch you want to switch to.\n\n```bash\n   git checkout branchName\n```\n\n![Git Branch](./screenshots/git-checkout.png)\n\n**Description :**\n\n- When used without options, git branch lists all the local branches in the repository.\n  The current branch is indicated with an asterisk (\\*).\n- Can create a new branch by providing a name after the git branch command.\n- To delete a branch, use the -d option followed by the name of the branch you want to delete.\n\n## Git Checkout\n\nThe `git checkout` command is used to switch branches in a Git repository. It allows you to view, create, or delete branches in a Git repository.\n**Example**\n\n```bash\n   git checkout branch-1\n```\n\n![Git Add](./screenshots/git-checkout.png)\n\n**Description :**\n\n- `git checkout`: This is the command to switch branches in a Git repository.\n- `branch-1`: This is the name of the branch you want to switch to.\n\n[Back to Top](#git-setup)\n\n## Git Merge\n\nThe `git merge` command is used to merge changes from one branch into another branch in a Git repository.\n\n**Example**\n\n```bash\n   git merge branch1\n```\n\n![Git Merge](./screenshots/git-merge.png)\n\n**Description :**\n\n- `git merge`: This is the command to merge changes from one branch into another branch in a Git repository.\n- `branch-1`: This is the name of the branch you want to merge into the current branch.\n\n### Git Rebase\n\nThe `git rebase` command is used to rebase the changes in the current branch onto the specified branch.\n\n**Example**\n\n```bash\n   git rebase \u003cbranchName\u003e\n```\n\n![Git Rebase](./screenshots/git-rebase.png)\n\n**Description :**\n\n- `git rebase` creates a new commit that reverts the changes introduced by the specified branch.\n- It modifies the commit history and creates a new commit with the same changes as the last commit.\n- `git rebase` is useful for creating a new commit with the same changes as the last commit without modifying the commit history.\n\n[Back to Top](#git-setup)\n\n# Collaboration\n\n## Git Remote\n\nThe `git remote` command allows you to manage the remote repositories associated with your local repository. You can add, rename, remove, and view information about remotes.\n**Example**\n\n1. `git remote -v`: Lists all remote repositories along with their URLs.\n\n```bash\n   git remote --v\n```\n\n![Git Remote](./screenshots/git-remote--v.png)\n\n2. `git remote add \u003cname of origin\u003e \u003curl\u003e `: Adds a new remote repository.\n\n```bash\n   git remote add origin https://github.com/pathURL.git\n```\n\n3. `git remote remove \u003cname\u003e `: Removes the specified remote repository.\n\n```bash\n   git remote remove \u003cname\u003e\n```\n\n**Description :**\n\n- The -v option stands for \"verbose,\" and it displays both the URL of the remote repository and its nickname.\n- When clone a repository, Git automatically creates a remote called origin that points to the original repository.\n- add multiple remotes to your repository to collaborate with others or to manage different hosting services.\n\n## Git Push\n\nThe `git push` command is used to upload local repository content to a remote repository.\n\n**Example**\nTo push the commits from the local main branch to the main branch on the remote repository named origin:\n\n```bash\n   git push origin main\n```\n\n![Git Remote](./screenshots/git-push.png)\n**Description :**\n\n- `git push`: This is the command to push your local commits to a remote repository.\n- `origin`: This is the default name Git gives to the server from which you cloned your repository. It represents the remote repository.\n- `main`: This is the name of the branch you want to push your commits to on the remote repository.\n\n### Git Fetch\n\nThe `git fetch` command is used to download the latest data from a remote repository without merging it with the data in your local repository.\n**Example**\n\n```bash\n   git fetch origin\n```\n\n![Git Pull](./screenshots/git-pull.png)\n\n**Description :**\n\n- `git fetch` retrieves the latest changes from the remote repository specified by its name (e.g., origin).\n- It downloads new branches, tags, and commits from the remote repository without modifying your local branches.\n- After fetching, you can inspect the changes using commands like git log or git diff.\n- `git fetch` is useful for updating your local repository with changes from the remote repository without automatically merging them into your working branch.\n\n## Git Pull\n\nThe `git pull` command is used to fetch and integrate changes from a remote repository into the current branch of your local repository.\n**Example**\n\n```bash\n   git pull origin main\n```\n\n![Git Pull](./screenshots/git-pull.png)\n**Description :**\n\n- git pull is a combination of two other Git commands: git fetch and git merge.\n- It fetches changes from the specified remote repository and integrates them into the current branch.\n- The \u003cremote\u003e argument specifies the remote repository from which - want to pull changes, and \u003cbranch\u003e specifies the branch from which you want to pull changes.\n- After fetching the changes, git pull automatically merges them into your current branch.\n\n[Back to Top](#git-setup)\n\n# Git Undoing changes\n\n## Git Reset\n\nThe `git reset` command is used to reset the current HEAD to a specified state. It can be used to undo changes, unstage files, or move the HEAD to a different commit.\n\n**Example**\n\n```bash\n   git reset HEAD~1\n```\n\n![Git Reset](./screenshots/git-reset.png)\n\n- git reset --hard moves the HEAD to the specified commit and discards all changes after that commit.\n\n**Git Reset Soft and Hard**\n\n- `git reset --soft` moves the HEAD to the specified commit, keeping the changes in the index.\n\n```bash\n   git reset --soft HEAD~1\n\n```\n\n![Git Reset](./screenshots/git-reset-soft.png)\n\n- `git reset --hard` moves the HEAD to the specified commit and discards all changes after that commit.\n\n```bash\n   git reset --hard HEAD~1\n```\n\n![Git Reset](./screenshots/git-reset--hard.png)\n\n**Description :**\n\n- `git reset` is a versatile command with different options for resetting the repository state.\n- With `git reset HEAD~1`, the HEAD moves back one commit, effectively undoing the last commit and keeping changes in the working directory.\n- Depending on the options used (soft, mixed, or hard), git reset can reset the staging area, working directory, or both.\n\n## Git Revert\n\nThe `git revert` command is used to undo changes made in previous commits. It creates a new commit that reverts the changes made in the specified commit.\n\n**Example**\n\n```bash\n   git revert \u003ccommitHash\u003e\n```\n\n## Git Rm\n\nThe `git rm` command is used to remove files from the working directory and the staging area. It removes the specified files from the working directory and the staging area.\n\n**Example**\n\n```bash\n   git rm textFile1.txt\n```\n\n![Git rm](./screenshots/git-rm.png)\n\n**Description :**\n\n- `git rm` removes files from the working directory and the staging area.\n- It removes the specified files from the working directory and the staging area.\n- `git rm` is useful for undoing changes made to files in the working directory or staging area.\n\n[Back to Top](#git-setup)\n\n**Description :**\n\n- `git revert` creates a new commit that undoes the changes introduced by the specified commit.\n- It does not modify the commit history but instead creates a new commit with the reversed changes.\n- Multiple commits can be reverted in a single command by specifying their commit hashes.\n- Reverting a merge commit requires specifying the parent commit to revert to.\n\n## Git Amend\n\nThe `git amend` command is used to amend the last commit with the changes made in the current commit. It creates a new commit with the same changes as the last commit.\n\n**Example**\n\n```bash\n   git amend\n```\n\n**Description :**\n\n- `git amend` creates a new commit with the same changes as the last commit.\n- It does not modify the commit history but instead creates a new commit with the same changes as the last commit.\n- `git amend` is useful for creating a new commit with the same changes as the last commit without modifying the commit history.\n\n## Git Cherry Pick\n\nThe `git cherry-pick` command is used to rebase the changes in the current branch onto the specified branch.\n\n**Example**\n\n```bash\n   git cherry-pick \u003ccommitHashCode\u003e\n```\n\n**Description :**\n\n- `git cherry-pick` creates a new commit that reverts the changes introduced by the specified commit.\n- It does not modify the commit history but instead creates a new commit with the reversed changes.\n- Multiple commits can be cherry-picked in a single command by specifying their commit hashes.\n- Cherry-picking a merge commit requires specifying the parent commit to cherry-pick from.\n\n![Git Cherry Pick](./screenshots/git-cherry-pick.png)\n\n[Back to Top](#git-setup)\n\n## Git Ignore Files\n\nThe `.gitignore` file tells Git which files (or patterns) it should ignore. This is useful for excluding temporary files, build artifacts, and other files that you do not want to commit to your repository.\n\n1. Navigate to your Git repository's root directory.\n2. Create a `.gitignore` file if it does not already exist:\n\n```bash\n   touch .gitignore\n```\n\n**Examples**\n\n```bash\n# Ignore node_modules directory\nnode_modules/\n\n# Ignore log files\n*.log\n\n# Ignore OS-specific files\n.DS_Store\nThumbs.db\n\n# Ignore build outputs\n/dist\n\n# Ignore environment files\n.env\n```\n\n##### Common .gitignore Patterns\n\n- \\*.log – Ignores all .log files.\n- \\*.tmp – Ignores all .tmp files.\n- node_modules/ – Ignores the node_modules - directory.\n- dist/ – Ignores the dist directory.\n- .DS_Store – Ignores macOS specific file.\n- Thumbs.db – Ignores Windows specific file.\n\n**Description :**\nBy properly configuring your .gitignore file, you can ensure that unnecessary files are not included in your Git repository, keeping your project clean and organized.\n\n[Back to Top](#git-setup)\n\n## Git References\n\n- [Git Official Documentation](https://git-scm.com/doc)\n- [Git Cheat Sheet](https://www.git-scm.com/cheat-sheet/)\n- [Git Guide Book](https://git-scm.com/book/en/v2)\n- [Git Tutorial](https://www.tutorialspoint.com/git/index.htm)\n- [Git Glossary](https://git-scm.com/docs/glossary)\n\n[Back to Top](#git-setup)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazrat16%2Fgit-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhazrat16%2Fgit-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazrat16%2Fgit-cheat-sheet/lists"}