[
  {
    "path": ".github/workflows/deploy-docs.yml",
    "content": "name: Deploy GitBook\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  build-and-deploy:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout Repository\n        uses: actions/checkout@v3\n\n      - name: Setup Node.js\n        uses: actions/setup-node@v3\n        with:\n          node-version: 20\n\n      - name: Install Dependencies\n        run: npm ci\n\n      - name: Build Docs\n        run: npm run docs:build\n\n      - name: Deploy to GitHub Pages\n        uses: peaceiris/actions-gh-pages@v3\n        with:\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n          publish_dir: ./docs/_book\n"
  },
  {
    "path": ".gitignore",
    "content": ".idea\nnode_modules\nnpm-debug.log\ndocs/_book\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n    \"eslint.enable\": false,\n    \"vsicons.presets.angular\": false\n}"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and maintainers pledge to making participation in our project and\nour community a harassment-free experience for everyone, regardless of age, body\nsize, disability, ethnicity, sex characteristics, gender identity and expression,\nlevel of experience, education, socio-economic status, nationality, personal\nappearance, race, religion, or sexual identity and orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment\ninclude:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or\n advances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic\n address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable\nbehavior and are expected to take appropriate and fair corrective action in\nresponse to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or\nreject comments, commits, code, wiki edits, issues, and other contributions\nthat are not aligned to this Code of Conduct, or to ban temporarily or\npermanently any contributor for other behaviors that they deem inappropriate,\nthreatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces\nwhen an individual is representing the project or its community. Examples of\nrepresenting a project or community include using an official project e-mail\naddress, posting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event. Representation of a project may be\nfurther defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported by contacting the project team at hemanth.hm@gmail.com. All\ncomplaints will be reviewed and investigated and will result in a response that\nis deemed necessary and appropriate to the circumstances. The project team is\nobligated to maintain confidentiality with regard to the reporter of an incident.\nFurther details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good\nfaith may face temporary or permanent repercussions as determined by other\nmembers of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,\navailable at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html\n\n[homepage]: https://www.contributor-covenant.org\n\nFor answers to common questions about this code of conduct, see\nhttps://www.contributor-covenant.org/faq\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Hemanth.HM <hemanth.hm@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "## git-tips\n> Collection of `git-tips`, want to add your tips? Checkout [contributing.md](./contributing.md)\n\n[English](http://git.io/git-tips) | [中文](https://github.com/521xueweihan/git-tips) | [Русский](https://github.com/Imangazaliev/git-tips) | [한국어](https://github.com/mingrammer/git-tips) | [Tiếng Việt](https://github.com/hprobotic/git-tips) | [日本語](https://github.com/isotai/git-tips) | [नेपाली](https://github.com/amarduwal/git-tips) | [Polski](https://github.com/mbiesiad/tips) | [فارسی](https://github.com/javadnikbakht/git-tips)\n\n### __Tools:__\n\n* [git-tip](https://www.npmjs.com/package/git-tip) - A handy CLI to make optimum use of these tips. ([Here in Docker container](https://github.com/djoudi5/docker-git-tip))\n\n📖 **[Read the interactive GitBook documentation here!](https://git-tips.github.io/tips/)**\n\nP.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`.\n\n## Table of Contents\n\n* [Basic Operations](#basic-operations)\n  * [List of all files till a commit](#list-of-all-files-till-a-commit)\n  * [Quickly switch to the previous branch](#quickly-switch-to-the-previous-branch)\n  * [Delete remote branch](#delete-remote-branch)\n  * [Delete remote tag](#delete-remote-tag)\n  * [Undo local changes with the content in index(staging)](#undo-local-changes-with-the-content-in-indexstaging)\n  * [Reword the previous commit message](#reword-the-previous-commit-message)\n  * [See commit history for just the current branch](#see-commit-history-for-just-the-current-branch)\n  * [Amend author.](#amend-author)\n  * [Stage parts of a changed file, instead of the entire file](#stage-parts-of-a-changed-file-instead-of-the-entire-file)\n  * [Pick commits across branches using cherry-pick](#pick-commits-across-branches-using-cherry-pick)\n  * [Grab a single file from a stash](#grab-a-single-file-from-a-stash)\n  * [Create new working tree from a repository (git 2.5)](#create-new-working-tree-from-a-repository-git-25)\n  * [Create new working tree from HEAD state](#create-new-working-tree-from-head-state)\n  * [Show all commits in the current branch yet to be merged to master](#show-all-commits-in-the-current-branch-yet-to-be-merged-to-master)\n  * [Modify previous commit without modifying the commit message](#modify-previous-commit-without-modifying-the-commit-message)\n  * [Prunes references to remove branches that have been deleted in the remote.](#prunes-references-to-remove-branches-that-have-been-deleted-in-the-remote)\n  * [Retrieve the commit hash of the initial revision.](#retrieve-the-commit-hash-of-the-initial-revision)\n  * [Import from a bundle](#import-from-a-bundle)\n  * [Ignore one file on commit (e.g. Changelog).](#ignore-one-file-on-commit-eg-changelog)\n  * [Fetch pull request by ID to a local branch](#fetch-pull-request-by-id-to-a-local-branch)\n  * [Restore deleted file.](#restore-deleted-file)\n  * [Restore file to a specific commit-hash](#restore-file-to-a-specific-commit-hash)\n  * [Marks your commit as a fix of a previous commit.](#marks-your-commit-as-a-fix-of-a-previous-commit)\n  * [Skip staging area during commit.](#skip-staging-area-during-commit)\n  * [Interactive staging.](#interactive-staging)\n  * [Status of ignored files.](#status-of-ignored-files)\n  * [Checkout a new branch without any history](#checkout-a-new-branch-without-any-history)\n  * [Find guilty with binary search](#find-guilty-with-binary-search)\n  * [Bypass pre-commit and commit-msg githooks](#bypass-pre-commit-and-commit-msg-githooks)\n  * [Clone a single branch](#clone-a-single-branch)\n  * [Create and switch new branch](#create-and-switch-new-branch)\n  * [Show all local branches ordered by recent commits](#show-all-local-branches-ordered-by-recent-commits)\n  * [Clone a shallow copy of a repository](#clone-a-shallow-copy-of-a-repository)\n  * [Force push to Remote Repository](#force-push-to-remote-repository)\n  * [Group commits by authors and title](#group-commits-by-authors-and-title)\n  * [Forced push but still ensure you don't overwrite other's work](#forced-push-but-still-ensure-you-dont-overwrite-others-work)\n  * [Number of commits in a branch](#number-of-commits-in-a-branch)\n  * [Add object notes](#add-object-notes)\n  * [Apply commit from another repository](#apply-commit-from-another-repository)\n  * [Specific fetch reference](#specific-fetch-reference)\n  * [Generates a summary of pending changes](#generates-a-summary-of-pending-changes)\n  * [Show git status short](#show-git-status-short)\n  * [Checkout a commit prior to a day ago](#checkout-a-commit-prior-to-a-day-ago)\n  * [Push the current branch to the same name on the remote repository](#push-the-current-branch-to-the-same-name-on-the-remote-repository)\n  * [Push a new local branch to remote repository and track](#push-a-new-local-branch-to-remote-repository-and-track)\n  * [Update a submodule to the latest commit](#update-a-submodule-to-the-latest-commit)\n  * [Duplicating a repository](#duplicating-a-repository)\n* [Branching](#branching)\n  * [List all branches that are already merged into master](#list-all-branches-that-are-already-merged-into-master)\n  * [Remove branches that have already been merged with master](#remove-branches-that-have-already-been-merged-with-master)\n  * [List all branches and their upstreams, as well as last commit on branch](#list-all-branches-and-their-upstreams-as-well-as-last-commit-on-branch)\n  * [Track upstream branch](#track-upstream-branch)\n  * [Delete local branch](#delete-local-branch)\n  * [Get list of all local and remote branches](#get-list-of-all-local-and-remote-branches)\n  * [Get only remote branches](#get-only-remote-branches)\n  * [Find out branches containing commit-hash](#find-out-branches-containing-commit-hash)\n  * [Rename a branch](#rename-a-branch)\n  * [Archive the `master` branch](#archive-the-master-branch)\n  * [Delete local branches that has been squash and merged in the remote.](#delete-local-branches-that-has-been-squash-and-merged-in-the-remote)\n  * [Export a branch with history to a file.](#export-a-branch-with-history-to-a-file)\n  * [Get the name of current branch.](#get-the-name-of-current-branch)\n  * [Show the most recent tag on the current branch.](#show-the-most-recent-tag-on-the-current-branch)\n  * [List all branch is WIP](#list-all-branch-is-wip)\n  * [Preformatted patch file.](#preformatted-patch-file)\n  * [Switch to a branch (modern alternative to checkout)](#switch-to-a-branch-modern-alternative-to-checkout)\n* [Log and History](#log-and-history)\n  * [Show helpful guides that come with Git](#show-helpful-guides-that-come-with-git)\n  * [Search change by content](#search-change-by-content)\n  * [Show changes over time for specific file](#show-changes-over-time-for-specific-file)\n  * [List all the conflicted files](#list-all-the-conflicted-files)\n  * [List of all files changed in a commit](#list-of-all-files-changed-in-a-commit)\n  * [Unstaged changes since last commit](#unstaged-changes-since-last-commit)\n  * [Changes staged for commit](#changes-staged-for-commit)\n  * [Show both staged and unstaged changes](#show-both-staged-and-unstaged-changes)\n  * [What changed since two weeks?](#what-changed-since-two-weeks)\n  * [See all commits made since forking from master](#see-all-commits-made-since-forking-from-master)\n  * [Show all tracked files](#show-all-tracked-files)\n  * [Show all untracked files](#show-all-untracked-files)\n  * [Show all ignored files](#show-all-ignored-files)\n  * [Visualize the version tree.](#visualize-the-version-tree)\n  * [Visualize the tree including commits that are only referenced from reflogs](#visualize-the-tree-including-commits-that-are-only-referenced-from-reflogs)\n  * [Show inline word diff.](#show-inline-word-diff)\n  * [Show changes using common diff tools.](#show-changes-using-common-diff-tools)\n  * [Commits in Branch1 that are not in Branch2](#commits-in-branch1-that-are-not-in-branch2)\n  * [List n last commits](#list-n-last-commits)\n  * [Open all conflicted files in an editor.](#open-all-conflicted-files-in-an-editor)\n  * [View the GPG signatures in the commit log](#view-the-gpg-signatures-in-the-commit-log)\n  * [Extract file from another branch.](#extract-file-from-another-branch)\n  * [List only the root and merge commits.](#list-only-the-root-and-merge-commits)\n  * [List commits and changes to a specific file (even through renaming)](#list-commits-and-changes-to-a-specific-file-even-through-renaming)\n  * [Search Commit log across all branches for given text](#search-commit-log-across-all-branches-for-given-text)\n  * [Get first commit in a branch (from master)](#get-first-commit-in-a-branch-from-master)\n  * [Show the author, time and last revision made to each line of a given file](#show-the-author-time-and-last-revision-made-to-each-line-of-a-given-file)\n  * [Show how many lines does an author contribute](#show-how-many-lines-does-an-author-contribute)\n  * [Show all the git-notes](#show-all-the-git-notes)\n  * [List unpushed git commits](#list-unpushed-git-commits)\n  * [Add everything, but whitespace changes](#add-everything-but-whitespace-changes)\n  * [blame on certain range](#blame-on-certain-range)\n  * [Show a Git logical variable.](#show-a-git-logical-variable)\n  * [Get the repo name.](#get-the-repo-name)\n  * [logs between date range](#logs-between-date-range)\n  * [Exclude author from logs](#exclude-author-from-logs)\n  * [View expanded details of changes in last commit](#view-expanded-details-of-changes-in-last-commit)\n  * [Visualize each position of HEAD in the last 30 days](#visualize-each-position-of-head-in-the-last-30-days)\n* [Merging and Rebasing](#merging-and-rebasing)\n  * [Rebases 'feature' to 'master' and merges it in to master ](#rebases-feature-to-master-and-merges-it-in-to-master-)\n  * [Stash changes before rebasing](#stash-changes-before-rebasing)\n  * [Squash fixup commits normal commits.](#squash-fixup-commits-normal-commits)\n  * [Change previous two commits with an interactive rebase.](#change-previous-two-commits-with-an-interactive-rebase)\n  * [Find common ancestor of two branches](#find-common-ancestor-of-two-branches)\n  * [Change a branch base](#change-a-branch-base)\n* [Miscellaneous](#miscellaneous)\n  * [Everyday Git in twenty commands or so](#everyday-git-in-twenty-commands-or-so)\n  * [Untrack files without deleting](#untrack-files-without-deleting)\n  * [Don’t consider changes for tracked file.](#dont-consider-changes-for-tracked-file)\n  * [Check if the change was a part of a release.](#check-if-the-change-was-a-part-of-a-release)\n  * [List ignored files.](#list-ignored-files)\n  * [Count unpacked number of objects and their disk consumption.](#count-unpacked-number-of-objects-and-their-disk-consumption)\n  * [Prune all unreachable objects from the object database.](#prune-all-unreachable-objects-from-the-object-database)\n  * [Instantly browse your working repository in gitweb.](#instantly-browse-your-working-repository-in-gitweb)\n  * [Find lines matching the pattern (regex or string) in tracked files](#find-lines-matching-the-pattern-regex-or-string-in-tracked-files)\n  * [Backup untracked files.](#backup-untracked-files)\n  * [Send a collection of patches as emails](#send-a-collection-of-patches-as-emails)\n* [Remotes](#remotes)\n  * [Changing a remote's URL](#changing-a-remotes-url)\n  * [Get list of all remote references](#get-list-of-all-remote-references)\n  * [Adding Remote name](#adding-remote-name)\n  * [List all currently configured remotes](#list-all-currently-configured-remotes)\n  * [List references in a remote repository](#list-references-in-a-remote-repository)\n  * [Refresh the list of remote branches](#refresh-the-list-of-remote-branches)\n* [Setup and Config](#setup-and-config)\n  * [Remove sensitive data from history, after a push](#remove-sensitive-data-from-history-after-a-push)\n  * [Reset author, after author has been changed in the global config.](#reset-author-after-author-has-been-changed-in-the-global-config)\n  * [Get git bash completion](#get-git-bash-completion)\n  * [Git Aliases](#git-aliases)\n  * [Always rebase instead of merge on pull.](#always-rebase-instead-of-merge-on-pull)\n  * [List all the alias and configs.](#list-all-the-alias-and-configs)\n  * [Make git case sensitive.](#make-git-case-sensitive)\n  * [Add custom editors.](#add-custom-editors)\n  * [Auto correct typos.](#auto-correct-typos)\n  * [Reuse recorded resolution, record and reuse previous conflicts resolutions.](#reuse-recorded-resolution-record-and-reuse-previous-conflicts-resolutions)\n  * [Remove entry in the global config.](#remove-entry-in-the-global-config)\n  * [Ignore file mode changes on commits](#ignore-file-mode-changes-on-commits)\n  * [Turn off git colored terminal output](#turn-off-git-colored-terminal-output)\n  * [Specific color settings](#specific-color-settings)\n  * [Alias: git undo](#alias-git-undo)\n  * [Edit [local/global] git config](#edit-localglobal-git-config)\n  * [List all git aliases](#list-all-git-aliases)\n  * [Use SSH instead of HTTPs for remotes](#use-ssh-instead-of-https-for-remotes)\n  * [Prevent auto replacing LF with CRLF](#prevent-auto-replacing-lf-with-crlf)\n  * [Edit config for each level](#edit-config-for-each-level)\n* [Stashing](#stashing)\n  * [Saving current state of tracked files without committing](#saving-current-state-of-tracked-files-without-committing)\n  * [Saving current state of unstaged changes to tracked files](#saving-current-state-of-unstaged-changes-to-tracked-files)\n  * [Saving current state including untracked files](#saving-current-state-including-untracked-files)\n  * [Saving current state with message](#saving-current-state-with-message)\n  * [Saving current state of all files (ignored, untracked, and tracked)](#saving-current-state-of-all-files-ignored-untracked-and-tracked)\n  * [Show list of all saved stashes](#show-list-of-all-saved-stashes)\n  * [Show the contents of any stash in patch form](#show-the-contents-of-any-stash-in-patch-form)\n  * [Apply any stash without deleting from the stashed list](#apply-any-stash-without-deleting-from-the-stashed-list)\n  * [Apply last stashed state and delete it from stashed list](#apply-last-stashed-state-and-delete-it-from-stashed-list)\n  * [Delete all stored stashes](#delete-all-stored-stashes)\n* [Submodules and Subtrees](#submodules-and-subtrees)\n  * [Update all the submodules](#update-all-the-submodules)\n  * [Deploying git tracked subfolder to gh-pages](#deploying-git-tracked-subfolder-to-gh-pages)\n  * [Adding a project to repo using subtree](#adding-a-project-to-repo-using-subtree)\n  * [Get latest changes in your repo for a linked project using subtree](#get-latest-changes-in-your-repo-for-a-linked-project-using-subtree)\n* [Tagging](#tagging)\n  * [Create local tag](#create-local-tag)\n  * [Delete local tag](#delete-local-tag)\n* [Undoing Changes](#undoing-changes)\n  * [Sync with remote, overwrite local changes](#sync-with-remote-overwrite-local-changes)\n  * [Git reset first commit](#git-reset-first-commit)\n  * [Reset: preserve uncommitted local changes](#reset-preserve-uncommitted-local-changes)\n  * [Revert: Undo a commit by creating a new commit](#revert-undo-a-commit-by-creating-a-new-commit)\n  * [Reset: Discard commits, advised for private branch](#reset-discard-commits-advised-for-private-branch)\n  * [Before deleting untracked files/directory, do a dry run to get the list of these files/directories](#before-deleting-untracked-filesdirectory-do-a-dry-run-to-get-the-list-of-these-filesdirectories)\n  * [Forcefully remove untracked files](#forcefully-remove-untracked-files)\n  * [Forcefully remove untracked directory](#forcefully-remove-untracked-directory)\n  * [Undo assume-unchanged.](#undo-assume-unchanged)\n  * [Clean the files from `.gitignore`.](#clean-the-files-from-gitignore)\n  * [Dry run. (any command that supports dry-run flag should do.)](#dry-run-any-command-that-supports-dry-run-flag-should-do)\n  * [Unstaging Staged file](#unstaging-staged-file)\n  * [Revert: Reverting an entire merge](#revert-reverting-an-entire-merge)\n  * [Restore file (modern alternative to reset/checkout --)](#restore-file-modern-alternative-to-resetcheckout---)\n\n## Basic Operations\n\n### List of all files till a commit\n```sh\ngit ls-tree --name-only -r <commit-ish>\n```\n\n### Quickly switch to the previous branch\n```sh\ngit checkout -\n```\n**Alternatives:**\n```sh\ngit checkout @{-1}\n```\n\n### Delete remote branch\n```sh\ngit push origin --delete <remote_branchname>\n```\n**Alternatives:**\n```sh\ngit push origin :<remote_branchname>\n```\n```sh\ngit branch -dr <remote/branch>\n```\n\n### Delete remote tag\n```sh\ngit push origin :refs/tags/<tag-name>\n```\n\n### Undo local changes with the content in index(staging)\n```sh\ngit checkout -- <file_name>\n```\n\n### Reword the previous commit message\n```sh\ngit commit -v --amend\n```\n\n### See commit history for just the current branch\n```sh\ngit cherry -v master\n```\n\n### Amend author.\n```sh\ngit commit --amend --author='Author Name <email@address.com>'\n```\n\n### Stage parts of a changed file, instead of the entire file\n```sh\ngit add -p\n```\n\n### Pick commits across branches using cherry-pick\n```sh\ngit checkout <branch-name> && git cherry-pick <commit-ish>\n```\n\n### Grab a single file from a stash\n```sh\ngit checkout <stash@{n}> -- <file_path>\n```\n**Alternatives:**\n```sh\ngit checkout stash@{0} -- <file_path>\n```\n\n### Create new working tree from a repository (git 2.5)\n```sh\ngit worktree add -b <branch-name> <path> <start-point>\n```\n\n### Create new working tree from HEAD state\n```sh\ngit worktree add --detach <path> HEAD\n```\n\n### Show all commits in the current branch yet to be merged to master\n```sh\ngit cherry -v master\n```\n**Alternatives:**\n```sh\ngit cherry -v master <branch-to-be-merged>\n```\n\n### Modify previous commit without modifying the commit message\n```sh\ngit add --all && git commit --amend --no-edit\n```\n\n### Prunes references to remove branches that have been deleted in the remote.\n```sh\ngit fetch -p\n```\n**Alternatives:**\n```sh\ngit remote prune origin\n```\n\n### Retrieve the commit hash of the initial revision.\n```sh\n git rev-list --reverse HEAD | head -1\n```\n**Alternatives:**\n```sh\ngit rev-list --max-parents=0 HEAD\n```\n```sh\ngit log --pretty=oneline | tail -1 | cut -c 1-40\n```\n```sh\ngit log --pretty=oneline --reverse | head -1 | cut -c 1-40\n```\n\n### Import from a bundle\n```sh\ngit clone repo.bundle <repo-dir> -b <branch-name>\n```\n\n### Ignore one file on commit (e.g. Changelog).\n```sh\ngit update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog\n```\n\n### Fetch pull request by ID to a local branch\n```sh\ngit fetch origin pull/<id>/head:<branch-name>\n```\n**Alternatives:**\n```sh\ngit pull origin pull/<id>/head:<branch-name>\n```\n\n### Restore deleted file.\n```sh\ngit checkout <deleting_commit> -- <file_path>\n```\n\n### Restore file to a specific commit-hash\n```sh\ngit checkout <commit-ish> -- <file_path>\n```\n\n### Marks your commit as a fix of a previous commit.\n```sh\ngit commit --fixup <SHA-1>\n```\n\n### Skip staging area during commit.\n```sh\ngit commit --only <file_path>\n```\n\n### Interactive staging.\n```sh\ngit add -i\n```\n\n### Status of ignored files.\n```sh\ngit status --ignored\n```\n\n### Checkout a new branch without any history\n```sh\ngit checkout --orphan <branch_name>\n```\n\n### Find guilty with binary search\n```sh\ngit bisect start                    # Search start \ngit bisect bad                      # Set point to bad commit \ngit bisect good v2.6.13-rc2         # Set point to good commit|tag \ngit bisect bad                      # Say current state is bad \ngit bisect good                     # Say current state is good \ngit bisect reset                    # Finish search \n\n```\n\n### Bypass pre-commit and commit-msg githooks\n```sh\ngit commit --no-verify\n```\n\n### Clone a single branch\n```sh\ngit clone -b <branch-name> --single-branch https://github.com/user/repo.git\n```\n\n### Create and switch new branch\n```sh\ngit checkout -b <branch-name>\n```\n**Alternatives:**\n```sh\ngit branch <branch-name> && git checkout <branch-name>\n```\n```sh\ngit switch -c <branch-name>\n```\n\n### Show all local branches ordered by recent commits\n```sh\ngit for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/\n```\n\n### Clone a shallow copy of a repository\n```sh\ngit clone https://github.com/user/repo.git --depth 1\n```\n\n### Force push to Remote Repository\n```sh\ngit push -f <remote-name> <branch-name>\n```\n\n### Group commits by authors and title\n```sh\ngit shortlog\n```\n\n### Forced push but still ensure you don't overwrite other's work\n```sh\ngit push --force-with-lease <remote-name> <branch-name>\n```\n\n### Number of commits in a branch\n```sh\ngit rev-list --count <branch-name>\n```\n\n### Add object notes\n```sh\ngit notes add -m 'Note on the previous commit....'\n```\n\n### Apply commit from another repository\n```sh\ngit --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | git am -3 -k\n```\n\n### Specific fetch reference\n```sh\ngit fetch origin master:refs/remotes/origin/mymaster\n```\n\n### Generates a summary of pending changes\n```sh\ngit request-pull v1.0 https://git.ko.xz/project master:for-linus\n```\n\n### Show git status short\n```sh\ngit status --short --branch\n```\n\n### Checkout a commit prior to a day ago\n```sh\ngit checkout master@{yesterday}\n```\n\n### Push the current branch to the same name on the remote repository\n```sh\ngit push origin HEAD\n```\n\n### Push a new local branch to remote repository and track\n```sh\ngit push -u origin <branch_name>\n```\n\n### Update a submodule to the latest commit\n```sh\ncd <path-to-submodule>\ngit pull origin <branch>\ncd <root-of-your-main-project>\ngit add <path-to-submodule>\ngit commit -m \"submodule updated\"\n```\n\n### Duplicating a repository\n```sh\ngit clone --bare https://github.com/exampleuser/old-repository.git\n\ngit push --mirror https://github.com/exampleuser/new-repository.git\n```\n\n## Branching\n\n### List all branches that are already merged into master\n```sh\ngit branch --merged master\n```\n\n### Remove branches that have already been merged with master\n```sh\ngit branch --merged master | grep -v '^\\*' | xargs -n 1 git branch -d\n```\n**Alternatives:**\n```sh\ngit branch --merged master | grep -v '^\\*\\|  master' | xargs -n 1 git branch -d # will not delete master if master is not checked out\n```\n\n### List all branches and their upstreams, as well as last commit on branch\n```sh\ngit branch -vv\n```\n\n### Track upstream branch\n```sh\ngit branch -u origin/mybranch\n```\n\n### Delete local branch\n```sh\ngit branch -d <local_branchname>\n```\n\n### Get list of all local and remote branches\n```sh\ngit branch -a\n```\n\n### Get only remote branches\n```sh\ngit branch -r\n```\n\n### Find out branches containing commit-hash\n```sh\ngit branch -a --contains <commit-ish>\n```\n**Alternatives:**\n```sh\ngit branch --contains <commit-ish>\n```\n\n### Rename a branch\n```sh\ngit branch -m <new-branch-name>\n```\n**Alternatives:**\n```sh\ngit branch -m [<old-branch-name>] <new-branch-name>\n```\n\n### Archive the `master` branch\n```sh\ngit archive master --format=zip --output=master.zip\n```\n\n### Delete local branches that has been squash and merged in the remote.\n```sh\ngit branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D\n```\n\n### Export a branch with history to a file.\n```sh\ngit bundle create <file> <branch-name>\n```\n\n### Get the name of current branch.\n```sh\ngit rev-parse --abbrev-ref HEAD\n```\n\n### Show the most recent tag on the current branch.\n```sh\ngit describe --tags --abbrev=0\n```\n\n### List all branch is WIP\n```sh\ngit checkout master && git branch --no-merged\n```\n\n### Preformatted patch file.\n```sh\ngit format-patch -M upstream..topic\n```\n\n### Switch to a branch (modern alternative to checkout)\n```sh\ngit switch <branch-name>\n```\n**Alternatives:**\n```sh\ngit switch -c <new-branch-name>\n```\n\n## Log and History\n\n### Show helpful guides that come with Git\n```sh\ngit help -g\n```\n\n### Search change by content\n```sh\ngit log -S'<a term in the source>'\n```\n\n### Show changes over time for specific file\n```sh\ngit log -p <file_name>\n```\n\n### List all the conflicted files\n```sh\ngit diff --name-only --diff-filter=U\n```\n\n### List of all files changed in a commit\n```sh\ngit diff-tree --no-commit-id --name-only -r <commit-ish>\n```\n\n### Unstaged changes since last commit\n```sh\ngit diff\n```\n\n### Changes staged for commit\n```sh\ngit diff --cached\n```\n**Alternatives:**\n```sh\ngit diff --staged\n```\n\n### Show both staged and unstaged changes\n```sh\ngit diff HEAD\n```\n\n### What changed since two weeks?\n```sh\ngit log --no-merges --raw --since='2 weeks ago'\n```\n**Alternatives:**\n```sh\ngit whatchanged --since='2 weeks ago'\n```\n\n### See all commits made since forking from master\n```sh\ngit log --no-merges --stat --reverse master..\n```\n\n### Show all tracked files\n```sh\ngit ls-files -t\n```\n\n### Show all untracked files\n```sh\ngit ls-files --others\n```\n\n### Show all ignored files\n```sh\ngit ls-files --others -i --exclude-standard\n```\n\n### Visualize the version tree.\n```sh\ngit log --pretty=oneline --graph --decorate --all\n```\n**Alternatives:**\n```sh\ngitk --all\n```\n```sh\ngit log --graph --pretty=format:'%C(auto) %h | %s | %an | %ar%d'\n```\n\n### Visualize the tree including commits that are only referenced from reflogs\n```sh\ngit log --graph --decorate --oneline $(git rev-list --walk-reflogs --all)\n```\n\n### Show inline word diff.\n```sh\ngit diff --word-diff\n```\n\n### Show changes using common diff tools.\n```sh\ngit difftool [-t <tool>] <commit1> <commit2> <path>\n```\n\n### Commits in Branch1 that are not in Branch2\n```sh\ngit log Branch1 ^Branch2\n```\n\n### List n last commits\n```sh\ngit log -<n>\n```\n**Alternatives:**\n```sh\ngit log -n <n>\n```\n\n### Open all conflicted files in an editor.\n```sh\ngit diff --name-only | uniq | xargs $EDITOR\n```\n\n### View the GPG signatures in the commit log\n```sh\ngit log --show-signature\n```\n\n### Extract file from another branch.\n```sh\ngit show <branch_name>:<file_name>\n```\n\n### List only the root and merge commits.\n```sh\ngit log --first-parent\n```\n\n### List commits and changes to a specific file (even through renaming)\n```sh\ngit log --follow -p -- <file_path>\n```\n\n### Search Commit log across all branches for given text\n```sh\ngit log --all --grep='<given-text>'\n```\n\n### Get first commit in a branch (from master)\n```sh\ngit log --oneline master..<branch-name> | tail -1\n```\n**Alternatives:**\n```sh\ngit log --reverse master..<branch-name> | head -6\n```\n\n### Show the author, time and last revision made to each line of a given file\n```sh\ngit blame <file-name>\n```\n\n### Show how many lines does an author contribute\n```sh\ngit log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s removed lines: %s total lines: %s\n\", add, subs, loc }' -\n```\n**Alternatives:**\n```sh\ngit log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s, removed lines: %s, total lines: %s\n\", add, subs, loc }' - # on Mac OSX\n```\n\n### Show all the git-notes\n```sh\ngit log --show-notes='*'\n```\n\n### List unpushed git commits\n```sh\ngit log --branches --not --remotes\n```\n**Alternatives:**\n```sh\ngit log @{u}..\n```\n```sh\ngit cherry -v\n```\n\n### Add everything, but whitespace changes\n```sh\ngit diff --ignore-all-space | git apply --cached\n```\n\n### blame on certain range\n```sh\ngit blame -L <start>,<end>\n```\n\n### Show a Git logical variable.\n```sh\ngit var -l | <variable>\n```\n\n### Get the repo name.\n```sh\ngit rev-parse --show-toplevel\n```\n\n### logs between date range\n```sh\ngit log --since='FEB 1 2017' --until='FEB 14 2017'\n```\n\n### Exclude author from logs\n```sh\ngit log --perl-regexp --author='^((?!excluded-author-regex).*)$'\n```\n\n### View expanded details of changes in last commit\n```sh\ngit show\n```\n\n### Visualize each position of HEAD in the last 30 days\n```sh\ngit reflog\n```\n\n## Merging and Rebasing\n\n### Rebases 'feature' to 'master' and merges it in to master \n```sh\ngit rebase master feature && git checkout master && git merge -\n```\n\n### Stash changes before rebasing\n```sh\ngit rebase --autostash\n```\n\n### Squash fixup commits normal commits.\n```sh\ngit rebase -i --autosquash\n```\n\n### Change previous two commits with an interactive rebase.\n```sh\ngit rebase --interactive HEAD~2\n```\n\n### Find common ancestor of two branches\n```sh\ngit merge-base <branch-name> <other-branch-name>\n```\n\n### Change a branch base\n```sh\ngit rebase --onto <new_base> <old_base>\n```\n\n## Miscellaneous\n\n### Everyday Git in twenty commands or so\n```sh\ngit help everyday\n```\n\n### Untrack files without deleting\n```sh\ngit rm --cached <file_path>\n```\n**Alternatives:**\n```sh\ngit rm --cached -r <directory_path>\n```\n\n### Don’t consider changes for tracked file.\n```sh\ngit update-index --assume-unchanged <file_name>\n```\n\n### Check if the change was a part of a release.\n```sh\ngit name-rev --name-only <SHA-1>\n```\n\n### List ignored files.\n```sh\ngit check-ignore *\n```\n\n### Count unpacked number of objects and their disk consumption.\n```sh\ngit count-objects --human-readable\n```\n\n### Prune all unreachable objects from the object database.\n```sh\ngit gc --prune=now --aggressive\n```\n\n### Instantly browse your working repository in gitweb.\n```sh\ngit instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]\n```\n\n### Find lines matching the pattern (regex or string) in tracked files\n```sh\ngit grep --heading --line-number 'foo bar'\n```\n\n### Backup untracked files.\n```sh\ngit ls-files --others -i --exclude-standard | xargs zip untracked.zip\n```\n\n### Send a collection of patches as emails\n```sh\ngit send-email [<options>] <file|directory>…\n\ngit send-email [<options>] <format-patch options>\n```\n\n## Remotes\n\n### Changing a remote's URL\n```sh\ngit remote set-url origin <URL>\n```\n\n### Get list of all remote references\n```sh\ngit remote\n```\n**Alternatives:**\n```sh\ngit remote show\n```\n\n### Adding Remote name\n```sh\ngit remote add <remote-nickname> <remote-url>\n```\n\n### List all currently configured remotes\n```sh\ngit remote -v\n```\n\n### List references in a remote repository\n```sh\ngit ls-remote git://git.kernel.org/pub/scm/git/git.git\n```\n\n### Refresh the list of remote branches\n```sh\ngit remote update origin --prune\n```\n\n## Setup and Config\n\n### Remove sensitive data from history, after a push\n```sh\ngit filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <path-to-your-file>' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all\n```\n\n### Reset author, after author has been changed in the global config.\n```sh\ngit commit --amend --reset-author --no-edit\n```\n\n### Get git bash completion\n```sh\ncurl -L http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrc\n```\n\n### Git Aliases\n```sh\ngit config --global alias.<handle> <command> \ngit config --global alias.st status\n```\n\n### Always rebase instead of merge on pull.\n```sh\ngit config --global pull.rebase true\n```\n**Alternatives:**\n```sh\n#git < 1.7.9\ngit config --global branch.autosetuprebase always\n```\n\n### List all the alias and configs.\n```sh\ngit config --list\n```\n\n### Make git case sensitive.\n```sh\ngit config --global core.ignorecase false\n```\n\n### Add custom editors.\n```sh\ngit config --global core.editor '$EDITOR'\n```\n\n### Auto correct typos.\n```sh\ngit config --global help.autocorrect 1\n```\n\n### Reuse recorded resolution, record and reuse previous conflicts resolutions.\n```sh\ngit config --global rerere.enabled 1\n```\n\n### Remove entry in the global config.\n```sh\ngit config --global --unset <entry-name>\n```\n\n### Ignore file mode changes on commits\n```sh\ngit config core.fileMode false\n```\n\n### Turn off git colored terminal output\n```sh\ngit config --global color.ui false\n```\n\n### Specific color settings\n```sh\ngit config --global <specific command e.g branch, diff> <true, false or always>\n```\n\n### Alias: git undo\n```sh\ngit config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'\n```\n\n### Edit [local/global] git config\n```sh\ngit config [--global] --edit\n```\n\n### List all git aliases\n```sh\ngit config -l | grep alias | sed 's/^alias\\.//g'\n```\n**Alternatives:**\n```sh\ngit config -l | grep alias | cut -d '.' -f 2\n```\n\n### Use SSH instead of HTTPs for remotes\n```sh\ngit config --global url.'git@github.com:'.insteadOf 'https://github.com/'\n```\n\n### Prevent auto replacing LF with CRLF\n```sh\ngit config --global core.autocrlf false\n```\n\n### Edit config for each level\n```sh\ngit config --edit --system\n\ngit config --edit --global\n\ngit config --edit --local\n```\n\n## Stashing\n\n### Saving current state of tracked files without committing\n```sh\ngit stash\n```\n**Alternatives:**\n```sh\ngit stash push\n```\n\n### Saving current state of unstaged changes to tracked files\n```sh\ngit stash -k\n```\n**Alternatives:**\n```sh\ngit stash --keep-index\n```\n```sh\ngit stash push --keep-index\n```\n\n### Saving current state including untracked files\n```sh\ngit stash -u\n```\n**Alternatives:**\n```sh\ngit stash push -u\n```\n```sh\ngit stash push --include-untracked\n```\n\n### Saving current state with message\n```sh\ngit stash push -m <message>\n```\n**Alternatives:**\n```sh\ngit stash push --message <message>\n```\n\n### Saving current state of all files (ignored, untracked, and tracked)\n```sh\ngit stash -a\n```\n**Alternatives:**\n```sh\ngit stash --all\n```\n```sh\ngit stash push --all\n```\n\n### Show list of all saved stashes\n```sh\ngit stash list\n```\n\n### Show the contents of any stash in patch form\n```sh\ngit stash show -p <stash@{n}>\n```\n\n### Apply any stash without deleting from the stashed list\n```sh\ngit stash apply <stash@{n}>\n```\n\n### Apply last stashed state and delete it from stashed list\n```sh\ngit stash pop\n```\n**Alternatives:**\n```sh\ngit stash apply stash@{0} && git stash drop stash@{0}\n```\n\n### Delete all stored stashes\n```sh\ngit stash clear\n```\n**Alternatives:**\n```sh\ngit stash drop <stash@{n}>\n```\n\n## Submodules and Subtrees\n\n### Update all the submodules\n```sh\ngit submodule foreach git pull\n```\n**Alternatives:**\n```sh\ngit submodule update --init --recursive\n```\n```sh\ngit submodule update --remote\n```\n\n### Deploying git tracked subfolder to gh-pages\n```sh\ngit subtree push --prefix subfolder_name origin gh-pages\n```\n**Alternatives:**\n```sh\ngit subtree push --prefix subfolder_name origin branch_name\n```\n\n### Adding a project to repo using subtree\n```sh\ngit subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master\n```\n\n### Get latest changes in your repo for a linked project using subtree\n```sh\ngit subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master\n```\n\n## Tagging\n\n### Create local tag\n```sh\ngit tag <tag-name>\n```\n\n### Delete local tag\n```sh\ngit tag -d <tag-name>\n```\n\n## Undoing Changes\n\n### Sync with remote, overwrite local changes\n```sh\ngit fetch origin && git reset --hard origin/master && git clean -f -d\n```\n\n### Git reset first commit\n```sh\ngit update-ref -d HEAD\n```\n\n### Reset: preserve uncommitted local changes\n```sh\ngit reset --keep <commit>\n```\n\n### Revert: Undo a commit by creating a new commit\n```sh\ngit revert <commit-ish>\n```\n\n### Reset: Discard commits, advised for private branch\n```sh\ngit reset <commit-ish>\n```\n\n### Before deleting untracked files/directory, do a dry run to get the list of these files/directories\n```sh\ngit clean -n\n```\n\n### Forcefully remove untracked files\n```sh\ngit clean -f\n```\n\n### Forcefully remove untracked directory\n```sh\ngit clean -f -d\n```\n\n### Undo assume-unchanged.\n```sh\ngit update-index --no-assume-unchanged <file_name>\n```\n\n### Clean the files from `.gitignore`.\n```sh\ngit clean -X -f\n```\n\n### Dry run. (any command that supports dry-run flag should do.)\n```sh\ngit clean -fd --dry-run\n```\n\n### Unstaging Staged file\n```sh\ngit reset HEAD <file-name>\n```\n\n### Revert: Reverting an entire merge\n```sh\ngit revert -m 1 <commit-ish>\n```\n\n### Restore file (modern alternative to reset/checkout --)\n```sh\ngit restore <file-name>\n```\n**Alternatives:**\n```sh\ngit restore --staged <file-name>\n```\n"
  },
  {
    "path": "book.json",
    "content": "{\n  \"title\": \"Git Tips\",\n  \"author\": \"hemanth\",\n  \"description\": \"Collection of most commonly used git tips and tricks.\",\n  \"root\": \"./docs\"\n}\n"
  },
  {
    "path": "build-readme.js",
    "content": "const fs = require('fs');\nconst tips = require('./tips.json');\n\nconst header = `## git-tips\n> Collection of \\`git-tips\\`, want to add your tips? Checkout [contributing.md](./contributing.md)\n\n[English](http://git.io/git-tips) | [中文](https://github.com/521xueweihan/git-tips) | [Русский](https://github.com/Imangazaliev/git-tips) | [한국어](https://github.com/mingrammer/git-tips) | [Tiếng Việt](https://github.com/hprobotic/git-tips) | [日本語](https://github.com/isotai/git-tips) | [नेपाली](https://github.com/amarduwal/git-tips) | [Polski](https://github.com/mbiesiad/tips) | [فارسی](https://github.com/javadnikbakht/git-tips)\n\n### __Tools:__\n\n* [git-tip](https://www.npmjs.com/package/git-tip) - A handy CLI to make optimum use of these tips. ([Here in Docker container](https://github.com/djoudi5/docker-git-tip))\n\n📖 **[Read the interactive GitBook documentation here!](https://git-tips.github.io/tips/)**\n\nP.S: All these commands are tested on \\`git version 2.7.4 (Apple Git-66)\\`.\n\n`;\n\nlet toc = \"## Table of Contents\\n\\n\";\nlet content = \"\";\n\nconst categories = {};\ntips.forEach(tip => {\n    const cat = tip.category || 'Miscellaneous';\n    if (!categories[cat]) categories[cat] = [];\n    categories[cat].push(tip);\n});\n\n// Generate TOC and Content\nObject.keys(categories).sort().forEach(cat => {\n    toc += `* [${cat}](#${cat.toLowerCase().replace(/ /g, '-')})\\n`;\n    content += `\\n## ${cat}\\n`;\n    categories[cat].forEach(tip => {\n        let slug = tip.title.toLowerCase().replace(/[^\\w\\- ]+/g, '').replace(/\\s+/g, '-');\n        toc += `  * [${tip.title}](#${slug})\\n`;\n        \n        content += `\\n### ${tip.title}\\n`;\n        content += `\\`\\`\\`sh\\n${tip.tip}\\n\\`\\`\\`\\n`;\n        if (tip.alternatives) {\n            content += `**Alternatives:**\\n`;\n            let alts = Array.isArray(tip.alternatives) ? tip.alternatives : [tip.alternatives];\n            alts.forEach(alt => {\n                content += `\\`\\`\\`sh\\n${alt}\\n\\`\\`\\`\\n`;\n            });\n        }\n    });\n});\n\nfs.writeFileSync('README.md', header + toc + content);\nconsole.log(\"README.md generated successfully!\");\n"
  },
  {
    "path": "contributing.md",
    "content": "## Easy steps:\n\n* [Fork](https://github.com/git-tips/tips/network) the repo.\n\n* Install the deps:\n ```sh\n  $ cd tips && npm install\n  ```\n\n :warning: don't fail to think that this is optional, because if you don't install the dependencies you won't get the benefit of auto-updating README and TOC and your PR will likely to not get merged because of that.\n\n* Edit [tips.json](./tips.json) to add your tip in the below format:\n\n```js\n{\n    \"title\": <your_tip_title>,\n    \"tip\": <your_tip>,\n    \"alternatives\": [Optional list of alternatives]\n}\n```\n\n* Commit, push and send a PR!\n"
  },
  {
    "path": "docs/README.md",
    "content": "# Git Tips\n\nWelcome to the Git Tips documentation! Browse through the categories in the sidebar to find useful Git commands and tricks.\n"
  },
  {
    "path": "docs/SUMMARY.md",
    "content": "# Summary\n\n* [Introduction](README.md)\n* [Basic Operations](basic-operations.md)\n* [Branching](branching.md)\n* [Log and History](log-and-history.md)\n* [Merging and Rebasing](merging-and-rebasing.md)\n* [Miscellaneous](miscellaneous.md)\n* [Remotes](remotes.md)\n* [Setup and Config](setup-and-config.md)\n* [Stashing](stashing.md)\n* [Submodules and Subtrees](submodules-and-subtrees.md)\n* [Tagging](tagging.md)\n* [Undoing Changes](undoing-changes.md)\n"
  },
  {
    "path": "docs/basic-operations.md",
    "content": "# Basic Operations\n\n## List of all files till a commit\n```sh\ngit ls-tree --name-only -r <commit-ish>\n```\n\n---\n\n## Quickly switch to the previous branch\n```sh\ngit checkout -\n```\n**Alternatives:**\n```sh\ngit checkout @{-1}\n```\n\n---\n\n## Delete remote branch\n```sh\ngit push origin --delete <remote_branchname>\n```\n**Alternatives:**\n```sh\ngit push origin :<remote_branchname>\n```\n```sh\ngit branch -dr <remote/branch>\n```\n\n---\n\n## Delete remote tag\n```sh\ngit push origin :refs/tags/<tag-name>\n```\n\n---\n\n## Undo local changes with the content in index(staging)\n```sh\ngit checkout -- <file_name>\n```\n\n---\n\n## Reword the previous commit message\n```sh\ngit commit -v --amend\n```\n\n---\n\n## See commit history for just the current branch\n```sh\ngit cherry -v master\n```\n\n---\n\n## Amend author.\n```sh\ngit commit --amend --author='Author Name <email@address.com>'\n```\n\n---\n\n## Stage parts of a changed file, instead of the entire file\n```sh\ngit add -p\n```\n\n---\n\n## Pick commits across branches using cherry-pick\n```sh\ngit checkout <branch-name> && git cherry-pick <commit-ish>\n```\n\n---\n\n## Grab a single file from a stash\n```sh\ngit checkout <stash@{n}> -- <file_path>\n```\n**Alternatives:**\n```sh\ngit checkout stash@{0} -- <file_path>\n```\n\n---\n\n## Create new working tree from a repository (git 2.5)\n```sh\ngit worktree add -b <branch-name> <path> <start-point>\n```\n\n---\n\n## Create new working tree from HEAD state\n```sh\ngit worktree add --detach <path> HEAD\n```\n\n---\n\n## Show all commits in the current branch yet to be merged to master\n```sh\ngit cherry -v master\n```\n**Alternatives:**\n```sh\ngit cherry -v master <branch-to-be-merged>\n```\n\n---\n\n## Modify previous commit without modifying the commit message\n```sh\ngit add --all && git commit --amend --no-edit\n```\n\n---\n\n## Prunes references to remove branches that have been deleted in the remote.\n```sh\ngit fetch -p\n```\n**Alternatives:**\n```sh\ngit remote prune origin\n```\n\n---\n\n## Retrieve the commit hash of the initial revision.\n```sh\n git rev-list --reverse HEAD | head -1\n```\n**Alternatives:**\n```sh\ngit rev-list --max-parents=0 HEAD\n```\n```sh\ngit log --pretty=oneline | tail -1 | cut -c 1-40\n```\n```sh\ngit log --pretty=oneline --reverse | head -1 | cut -c 1-40\n```\n\n---\n\n## Import from a bundle\n```sh\ngit clone repo.bundle <repo-dir> -b <branch-name>\n```\n\n---\n\n## Ignore one file on commit (e.g. Changelog).\n```sh\ngit update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog\n```\n\n---\n\n## Fetch pull request by ID to a local branch\n```sh\ngit fetch origin pull/<id>/head:<branch-name>\n```\n**Alternatives:**\n```sh\ngit pull origin pull/<id>/head:<branch-name>\n```\n\n---\n\n## Restore deleted file.\n```sh\ngit checkout <deleting_commit> -- <file_path>\n```\n\n---\n\n## Restore file to a specific commit-hash\n```sh\ngit checkout <commit-ish> -- <file_path>\n```\n\n---\n\n## Marks your commit as a fix of a previous commit.\n```sh\ngit commit --fixup <SHA-1>\n```\n\n---\n\n## Skip staging area during commit.\n```sh\ngit commit --only <file_path>\n```\n\n---\n\n## Interactive staging.\n```sh\ngit add -i\n```\n\n---\n\n## Status of ignored files.\n```sh\ngit status --ignored\n```\n\n---\n\n## Checkout a new branch without any history\n```sh\ngit checkout --orphan <branch_name>\n```\n\n---\n\n## Find guilty with binary search\n```sh\ngit bisect start                    # Search start \ngit bisect bad                      # Set point to bad commit \ngit bisect good v2.6.13-rc2         # Set point to good commit|tag \ngit bisect bad                      # Say current state is bad \ngit bisect good                     # Say current state is good \ngit bisect reset                    # Finish search \n\n```\n\n---\n\n## Bypass pre-commit and commit-msg githooks\n```sh\ngit commit --no-verify\n```\n\n---\n\n## Clone a single branch\n```sh\ngit clone -b <branch-name> --single-branch https://github.com/user/repo.git\n```\n\n---\n\n## Create and switch new branch\n```sh\ngit checkout -b <branch-name>\n```\n**Alternatives:**\n```sh\ngit branch <branch-name> && git checkout <branch-name>\n```\n```sh\ngit switch -c <branch-name>\n```\n\n---\n\n## Show all local branches ordered by recent commits\n```sh\ngit for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/\n```\n\n---\n\n## Clone a shallow copy of a repository\n```sh\ngit clone https://github.com/user/repo.git --depth 1\n```\n\n---\n\n## Force push to Remote Repository\n```sh\ngit push -f <remote-name> <branch-name>\n```\n\n---\n\n## Group commits by authors and title\n```sh\ngit shortlog\n```\n\n---\n\n## Forced push but still ensure you don't overwrite other's work\n```sh\ngit push --force-with-lease <remote-name> <branch-name>\n```\n\n---\n\n## Number of commits in a branch\n```sh\ngit rev-list --count <branch-name>\n```\n\n---\n\n## Add object notes\n```sh\ngit notes add -m 'Note on the previous commit....'\n```\n\n---\n\n## Apply commit from another repository\n```sh\ngit --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | git am -3 -k\n```\n\n---\n\n## Specific fetch reference\n```sh\ngit fetch origin master:refs/remotes/origin/mymaster\n```\n\n---\n\n## Generates a summary of pending changes\n```sh\ngit request-pull v1.0 https://git.ko.xz/project master:for-linus\n```\n\n---\n\n## Show git status short\n```sh\ngit status --short --branch\n```\n\n---\n\n## Checkout a commit prior to a day ago\n```sh\ngit checkout master@{yesterday}\n```\n\n---\n\n## Push the current branch to the same name on the remote repository\n```sh\ngit push origin HEAD\n```\n\n---\n\n## Push a new local branch to remote repository and track\n```sh\ngit push -u origin <branch_name>\n```\n\n---\n\n## Update a submodule to the latest commit\n```sh\ncd <path-to-submodule>\ngit pull origin <branch>\ncd <root-of-your-main-project>\ngit add <path-to-submodule>\ngit commit -m \"submodule updated\"\n```\n\n---\n\n## Duplicating a repository\n```sh\ngit clone --bare https://github.com/exampleuser/old-repository.git\n\ngit push --mirror https://github.com/exampleuser/new-repository.git\n```\n\n---\n\n"
  },
  {
    "path": "docs/branching.md",
    "content": "# Branching\n\n## List all branches that are already merged into master\n```sh\ngit branch --merged master\n```\n\n---\n\n## Remove branches that have already been merged with master\n```sh\ngit branch --merged master | grep -v '^\\*' | xargs -n 1 git branch -d\n```\n**Alternatives:**\n```sh\ngit branch --merged master | grep -v '^\\*\\|  master' | xargs -n 1 git branch -d # will not delete master if master is not checked out\n```\n\n---\n\n## List all branches and their upstreams, as well as last commit on branch\n```sh\ngit branch -vv\n```\n\n---\n\n## Track upstream branch\n```sh\ngit branch -u origin/mybranch\n```\n\n---\n\n## Delete local branch\n```sh\ngit branch -d <local_branchname>\n```\n\n---\n\n## Get list of all local and remote branches\n```sh\ngit branch -a\n```\n\n---\n\n## Get only remote branches\n```sh\ngit branch -r\n```\n\n---\n\n## Find out branches containing commit-hash\n```sh\ngit branch -a --contains <commit-ish>\n```\n**Alternatives:**\n```sh\ngit branch --contains <commit-ish>\n```\n\n---\n\n## Rename a branch\n```sh\ngit branch -m <new-branch-name>\n```\n**Alternatives:**\n```sh\ngit branch -m [<old-branch-name>] <new-branch-name>\n```\n\n---\n\n## Archive the `master` branch\n```sh\ngit archive master --format=zip --output=master.zip\n```\n\n---\n\n## Delete local branches that has been squash and merged in the remote.\n```sh\ngit branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D\n```\n\n---\n\n## Export a branch with history to a file.\n```sh\ngit bundle create <file> <branch-name>\n```\n\n---\n\n## Get the name of current branch.\n```sh\ngit rev-parse --abbrev-ref HEAD\n```\n\n---\n\n## Show the most recent tag on the current branch.\n```sh\ngit describe --tags --abbrev=0\n```\n\n---\n\n## List all branch is WIP\n```sh\ngit checkout master && git branch --no-merged\n```\n\n---\n\n## Preformatted patch file.\n```sh\ngit format-patch -M upstream..topic\n```\n\n---\n\n## Switch to a branch (modern alternative to checkout)\n```sh\ngit switch <branch-name>\n```\n**Alternatives:**\n```sh\ngit switch -c <new-branch-name>\n```\n\n---\n\n"
  },
  {
    "path": "docs/log-and-history.md",
    "content": "# Log and History\n\n## Show helpful guides that come with Git\n```sh\ngit help -g\n```\n\n---\n\n## Search change by content\n```sh\ngit log -S'<a term in the source>'\n```\n\n---\n\n## Show changes over time for specific file\n```sh\ngit log -p <file_name>\n```\n\n---\n\n## List all the conflicted files\n```sh\ngit diff --name-only --diff-filter=U\n```\n\n---\n\n## List of all files changed in a commit\n```sh\ngit diff-tree --no-commit-id --name-only -r <commit-ish>\n```\n\n---\n\n## Unstaged changes since last commit\n```sh\ngit diff\n```\n\n---\n\n## Changes staged for commit\n```sh\ngit diff --cached\n```\n**Alternatives:**\n```sh\ngit diff --staged\n```\n\n---\n\n## Show both staged and unstaged changes\n```sh\ngit diff HEAD\n```\n\n---\n\n## What changed since two weeks?\n```sh\ngit log --no-merges --raw --since='2 weeks ago'\n```\n**Alternatives:**\n```sh\ngit whatchanged --since='2 weeks ago'\n```\n\n---\n\n## See all commits made since forking from master\n```sh\ngit log --no-merges --stat --reverse master..\n```\n\n---\n\n## Show all tracked files\n```sh\ngit ls-files -t\n```\n\n---\n\n## Show all untracked files\n```sh\ngit ls-files --others\n```\n\n---\n\n## Show all ignored files\n```sh\ngit ls-files --others -i --exclude-standard\n```\n\n---\n\n## Visualize the version tree.\n```sh\ngit log --pretty=oneline --graph --decorate --all\n```\n**Alternatives:**\n```sh\ngitk --all\n```\n```sh\ngit log --graph --pretty=format:'%C(auto) %h | %s | %an | %ar%d'\n```\n\n---\n\n## Visualize the tree including commits that are only referenced from reflogs\n```sh\ngit log --graph --decorate --oneline $(git rev-list --walk-reflogs --all)\n```\n\n---\n\n## Show inline word diff.\n```sh\ngit diff --word-diff\n```\n\n---\n\n## Show changes using common diff tools.\n```sh\ngit difftool [-t <tool>] <commit1> <commit2> <path>\n```\n\n---\n\n## Commits in Branch1 that are not in Branch2\n```sh\ngit log Branch1 ^Branch2\n```\n\n---\n\n## List n last commits\n```sh\ngit log -<n>\n```\n**Alternatives:**\n```sh\ngit log -n <n>\n```\n\n---\n\n## Open all conflicted files in an editor.\n```sh\ngit diff --name-only | uniq | xargs $EDITOR\n```\n\n---\n\n## View the GPG signatures in the commit log\n```sh\ngit log --show-signature\n```\n\n---\n\n## Extract file from another branch.\n```sh\ngit show <branch_name>:<file_name>\n```\n\n---\n\n## List only the root and merge commits.\n```sh\ngit log --first-parent\n```\n\n---\n\n## List commits and changes to a specific file (even through renaming)\n```sh\ngit log --follow -p -- <file_path>\n```\n\n---\n\n## Search Commit log across all branches for given text\n```sh\ngit log --all --grep='<given-text>'\n```\n\n---\n\n## Get first commit in a branch (from master)\n```sh\ngit log --oneline master..<branch-name> | tail -1\n```\n**Alternatives:**\n```sh\ngit log --reverse master..<branch-name> | head -6\n```\n\n---\n\n## Show the author, time and last revision made to each line of a given file\n```sh\ngit blame <file-name>\n```\n\n---\n\n## Show how many lines does an author contribute\n```sh\ngit log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s removed lines: %s total lines: %s\n\", add, subs, loc }' -\n```\n**Alternatives:**\n```sh\ngit log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s, removed lines: %s, total lines: %s\n\", add, subs, loc }' - # on Mac OSX\n```\n\n---\n\n## Show all the git-notes\n```sh\ngit log --show-notes='*'\n```\n\n---\n\n## List unpushed git commits\n```sh\ngit log --branches --not --remotes\n```\n**Alternatives:**\n```sh\ngit log @{u}..\n```\n```sh\ngit cherry -v\n```\n\n---\n\n## Add everything, but whitespace changes\n```sh\ngit diff --ignore-all-space | git apply --cached\n```\n\n---\n\n## blame on certain range\n```sh\ngit blame -L <start>,<end>\n```\n\n---\n\n## Show a Git logical variable.\n```sh\ngit var -l | <variable>\n```\n\n---\n\n## Get the repo name.\n```sh\ngit rev-parse --show-toplevel\n```\n\n---\n\n## logs between date range\n```sh\ngit log --since='FEB 1 2017' --until='FEB 14 2017'\n```\n\n---\n\n## Exclude author from logs\n```sh\ngit log --perl-regexp --author='^((?!excluded-author-regex).*)$'\n```\n\n---\n\n## View expanded details of changes in last commit\n```sh\ngit show\n```\n\n---\n\n## Visualize each position of HEAD in the last 30 days\n```sh\ngit reflog\n```\n\n---\n\n"
  },
  {
    "path": "docs/merging-and-rebasing.md",
    "content": "# Merging and Rebasing\n\n## Rebases 'feature' to 'master' and merges it in to master \n```sh\ngit rebase master feature && git checkout master && git merge -\n```\n\n---\n\n## Stash changes before rebasing\n```sh\ngit rebase --autostash\n```\n\n---\n\n## Squash fixup commits normal commits.\n```sh\ngit rebase -i --autosquash\n```\n\n---\n\n## Change previous two commits with an interactive rebase.\n```sh\ngit rebase --interactive HEAD~2\n```\n\n---\n\n## Find common ancestor of two branches\n```sh\ngit merge-base <branch-name> <other-branch-name>\n```\n\n---\n\n## Change a branch base\n```sh\ngit rebase --onto <new_base> <old_base>\n```\n\n---\n\n"
  },
  {
    "path": "docs/miscellaneous.md",
    "content": "# Miscellaneous\n\n## Everyday Git in twenty commands or so\n```sh\ngit help everyday\n```\n\n---\n\n## Untrack files without deleting\n```sh\ngit rm --cached <file_path>\n```\n**Alternatives:**\n```sh\ngit rm --cached -r <directory_path>\n```\n\n---\n\n## Don’t consider changes for tracked file.\n```sh\ngit update-index --assume-unchanged <file_name>\n```\n\n---\n\n## Check if the change was a part of a release.\n```sh\ngit name-rev --name-only <SHA-1>\n```\n\n---\n\n## List ignored files.\n```sh\ngit check-ignore *\n```\n\n---\n\n## Count unpacked number of objects and their disk consumption.\n```sh\ngit count-objects --human-readable\n```\n\n---\n\n## Prune all unreachable objects from the object database.\n```sh\ngit gc --prune=now --aggressive\n```\n\n---\n\n## Instantly browse your working repository in gitweb.\n```sh\ngit instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]\n```\n\n---\n\n## Find lines matching the pattern (regex or string) in tracked files\n```sh\ngit grep --heading --line-number 'foo bar'\n```\n\n---\n\n## Backup untracked files.\n```sh\ngit ls-files --others -i --exclude-standard | xargs zip untracked.zip\n```\n\n---\n\n## Send a collection of patches as emails\n```sh\ngit send-email [<options>] <file|directory>…\n\ngit send-email [<options>] <format-patch options>\n```\n\n---\n\n"
  },
  {
    "path": "docs/remotes.md",
    "content": "# Remotes\n\n## Changing a remote's URL\n```sh\ngit remote set-url origin <URL>\n```\n\n---\n\n## Get list of all remote references\n```sh\ngit remote\n```\n**Alternatives:**\n```sh\ngit remote show\n```\n\n---\n\n## Adding Remote name\n```sh\ngit remote add <remote-nickname> <remote-url>\n```\n\n---\n\n## List all currently configured remotes\n```sh\ngit remote -v\n```\n\n---\n\n## List references in a remote repository\n```sh\ngit ls-remote git://git.kernel.org/pub/scm/git/git.git\n```\n\n---\n\n## Refresh the list of remote branches\n```sh\ngit remote update origin --prune\n```\n\n---\n\n"
  },
  {
    "path": "docs/setup-and-config.md",
    "content": "# Setup and Config\n\n## Remove sensitive data from history, after a push\n```sh\ngit filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <path-to-your-file>' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all\n```\n\n---\n\n## Reset author, after author has been changed in the global config.\n```sh\ngit commit --amend --reset-author --no-edit\n```\n\n---\n\n## Get git bash completion\n```sh\ncurl -L http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrc\n```\n\n---\n\n## Git Aliases\n```sh\ngit config --global alias.<handle> <command> \ngit config --global alias.st status\n```\n\n---\n\n## Always rebase instead of merge on pull.\n```sh\ngit config --global pull.rebase true\n```\n**Alternatives:**\n```sh\n#git < 1.7.9\ngit config --global branch.autosetuprebase always\n```\n\n---\n\n## List all the alias and configs.\n```sh\ngit config --list\n```\n\n---\n\n## Make git case sensitive.\n```sh\ngit config --global core.ignorecase false\n```\n\n---\n\n## Add custom editors.\n```sh\ngit config --global core.editor '$EDITOR'\n```\n\n---\n\n## Auto correct typos.\n```sh\ngit config --global help.autocorrect 1\n```\n\n---\n\n## Reuse recorded resolution, record and reuse previous conflicts resolutions.\n```sh\ngit config --global rerere.enabled 1\n```\n\n---\n\n## Remove entry in the global config.\n```sh\ngit config --global --unset <entry-name>\n```\n\n---\n\n## Ignore file mode changes on commits\n```sh\ngit config core.fileMode false\n```\n\n---\n\n## Turn off git colored terminal output\n```sh\ngit config --global color.ui false\n```\n\n---\n\n## Specific color settings\n```sh\ngit config --global <specific command e.g branch, diff> <true, false or always>\n```\n\n---\n\n## Alias: git undo\n```sh\ngit config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'\n```\n\n---\n\n## Edit [local/global] git config\n```sh\ngit config [--global] --edit\n```\n\n---\n\n## List all git aliases\n```sh\ngit config -l | grep alias | sed 's/^alias\\.//g'\n```\n**Alternatives:**\n```sh\ngit config -l | grep alias | cut -d '.' -f 2\n```\n\n---\n\n## Use SSH instead of HTTPs for remotes\n```sh\ngit config --global url.'git@github.com:'.insteadOf 'https://github.com/'\n```\n\n---\n\n## Prevent auto replacing LF with CRLF\n```sh\ngit config --global core.autocrlf false\n```\n\n---\n\n## Edit config for each level\n```sh\ngit config --edit --system\n\ngit config --edit --global\n\ngit config --edit --local\n```\n\n---\n\n"
  },
  {
    "path": "docs/stashing.md",
    "content": "# Stashing\n\n## Saving current state of tracked files without committing\n```sh\ngit stash\n```\n**Alternatives:**\n```sh\ngit stash push\n```\n\n---\n\n## Saving current state of unstaged changes to tracked files\n```sh\ngit stash -k\n```\n**Alternatives:**\n```sh\ngit stash --keep-index\n```\n```sh\ngit stash push --keep-index\n```\n\n---\n\n## Saving current state including untracked files\n```sh\ngit stash -u\n```\n**Alternatives:**\n```sh\ngit stash push -u\n```\n```sh\ngit stash push --include-untracked\n```\n\n---\n\n## Saving current state with message\n```sh\ngit stash push -m <message>\n```\n**Alternatives:**\n```sh\ngit stash push --message <message>\n```\n\n---\n\n## Saving current state of all files (ignored, untracked, and tracked)\n```sh\ngit stash -a\n```\n**Alternatives:**\n```sh\ngit stash --all\n```\n```sh\ngit stash push --all\n```\n\n---\n\n## Show list of all saved stashes\n```sh\ngit stash list\n```\n\n---\n\n## Show the contents of any stash in patch form\n```sh\ngit stash show -p <stash@{n}>\n```\n\n---\n\n## Apply any stash without deleting from the stashed list\n```sh\ngit stash apply <stash@{n}>\n```\n\n---\n\n## Apply last stashed state and delete it from stashed list\n```sh\ngit stash pop\n```\n**Alternatives:**\n```sh\ngit stash apply stash@{0} && git stash drop stash@{0}\n```\n\n---\n\n## Delete all stored stashes\n```sh\ngit stash clear\n```\n**Alternatives:**\n```sh\ngit stash drop <stash@{n}>\n```\n\n---\n\n"
  },
  {
    "path": "docs/submodules-and-subtrees.md",
    "content": "# Submodules and Subtrees\n\n## Update all the submodules\n```sh\ngit submodule foreach git pull\n```\n**Alternatives:**\n```sh\ngit submodule update --init --recursive\n```\n```sh\ngit submodule update --remote\n```\n\n---\n\n## Deploying git tracked subfolder to gh-pages\n```sh\ngit subtree push --prefix subfolder_name origin gh-pages\n```\n**Alternatives:**\n```sh\ngit subtree push --prefix subfolder_name origin branch_name\n```\n\n---\n\n## Adding a project to repo using subtree\n```sh\ngit subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master\n```\n\n---\n\n## Get latest changes in your repo for a linked project using subtree\n```sh\ngit subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master\n```\n\n---\n\n"
  },
  {
    "path": "docs/tagging.md",
    "content": "# Tagging\n\n## Create local tag\n```sh\ngit tag <tag-name>\n```\n\n---\n\n## Delete local tag\n```sh\ngit tag -d <tag-name>\n```\n\n---\n\n"
  },
  {
    "path": "docs/undoing-changes.md",
    "content": "# Undoing Changes\n\n## Sync with remote, overwrite local changes\n```sh\ngit fetch origin && git reset --hard origin/master && git clean -f -d\n```\n\n---\n\n## Git reset first commit\n```sh\ngit update-ref -d HEAD\n```\n\n---\n\n## Reset: preserve uncommitted local changes\n```sh\ngit reset --keep <commit>\n```\n\n---\n\n## Revert: Undo a commit by creating a new commit\n```sh\ngit revert <commit-ish>\n```\n\n---\n\n## Reset: Discard commits, advised for private branch\n```sh\ngit reset <commit-ish>\n```\n\n---\n\n## Before deleting untracked files/directory, do a dry run to get the list of these files/directories\n```sh\ngit clean -n\n```\n\n---\n\n## Forcefully remove untracked files\n```sh\ngit clean -f\n```\n\n---\n\n## Forcefully remove untracked directory\n```sh\ngit clean -f -d\n```\n\n---\n\n## Undo assume-unchanged.\n```sh\ngit update-index --no-assume-unchanged <file_name>\n```\n\n---\n\n## Clean the files from `.gitignore`.\n```sh\ngit clean -X -f\n```\n\n---\n\n## Dry run. (any command that supports dry-run flag should do.)\n```sh\ngit clean -fd --dry-run\n```\n\n---\n\n## Unstaging Staged file\n```sh\ngit reset HEAD <file-name>\n```\n\n---\n\n## Revert: Reverting an entire merge\n```sh\ngit revert -m 1 <commit-ish>\n```\n\n---\n\n## Restore file (modern alternative to reset/checkout --)\n```sh\ngit restore <file-name>\n```\n**Alternatives:**\n```sh\ngit restore --staged <file-name>\n```\n\n---\n\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"tips\",\n  \"version\": \"1.0.0\",\n  \"description\": \"collection of git tips\",\n  \"main\": \"index.js\",\n  \"private\": \"true\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n    \"precommit\": \"npm run generate && git add README.md\",\n    \"generate\": \"node build-readme.js\",\n    \"docs:build\": \"honkit build ./docs\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/npm-tips/tips.git\"\n  },\n  \"keywords\": [\n    \"npm\",\n    \"tips\"\n  ],\n  \"contributors\": [\n    \"hemanth\"\n  ],\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/git-tips/tips/issues\"\n  },\n  \"homepage\": \"https://github.com/git-tips/tips#readme\",\n  \"devDependencies\": {\n    \"honkit\": \"^6.1.6\",\n    \"husky\": \"^5.0.9\"\n  }\n}\n"
  },
  {
    "path": "tips.json",
    "content": "[\n    {\n        \"title\": \"Everyday Git in twenty commands or so\",\n        \"tip\": \"git help everyday\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Show helpful guides that come with Git\",\n        \"tip\": \"git help -g\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Search change by content\",\n        \"tip\": \"git log -S'<a term in the source>'\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Show changes over time for specific file\",\n        \"tip\": \"git log -p <file_name>\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Remove sensitive data from history, after a push\",\n        \"tip\": \"git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <path-to-your-file>' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Sync with remote, overwrite local changes\",\n        \"tip\": \"git fetch origin && git reset --hard origin/master && git clean -f -d\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"List of all files till a commit\",\n        \"tip\": \"git ls-tree --name-only -r <commit-ish>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Git reset first commit\",\n        \"tip\": \"git update-ref -d HEAD\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Reset: preserve uncommitted local changes\",\n        \"tip\": \"git reset --keep <commit>\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"List all the conflicted files\",\n        \"tip\": \"git diff --name-only --diff-filter=U\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"List of all files changed in a commit\",\n        \"tip\": \"git diff-tree --no-commit-id --name-only -r <commit-ish>\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Unstaged changes since last commit\",\n        \"tip\": \"git diff\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Changes staged for commit\",\n        \"tip\": \"git diff --cached\",\n        \"alternatives\": [\n            \"git diff --staged\"\n        ],\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Show both staged and unstaged changes\",\n        \"tip\": \"git diff HEAD\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"List all branches that are already merged into master\",\n        \"tip\": \"git branch --merged master\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Quickly switch to the previous branch\",\n        \"tip\": \"git checkout -\",\n        \"alternatives\": [\n            \"git checkout @{-1}\"\n        ],\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Remove branches that have already been merged with master\",\n        \"tip\": \"git branch --merged master | grep -v '^\\\\*' | xargs -n 1 git branch -d\",\n        \"alternatives\": [\n            \"git branch --merged master | grep -v '^\\\\*\\\\|  master' | xargs -n 1 git branch -d # will not delete master if master is not checked out\"\n        ],\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"List all branches and their upstreams, as well as last commit on branch\",\n        \"tip\": \"git branch -vv\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Track upstream branch\",\n        \"tip\": \"git branch -u origin/mybranch\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Delete local branch\",\n        \"tip\": \"git branch -d <local_branchname>\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Delete remote branch\",\n        \"tip\": \"git push origin --delete <remote_branchname>\",\n        \"alternatives\": [\n            \"git push origin :<remote_branchname>\",\n            \"git branch -dr <remote/branch>\"\n        ],\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Create local tag\",\n        \"tip\": \"git tag <tag-name>\",\n        \"category\": \"Tagging\"\n    },\n    {\n        \"title\": \"Delete local tag\",\n        \"tip\": \"git tag -d <tag-name>\",\n        \"category\": \"Tagging\"\n    },\n    {\n        \"title\": \"Delete remote tag\",\n        \"tip\": \"git push origin :refs/tags/<tag-name>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Undo local changes with the content in index(staging)\",\n        \"tip\": \"git checkout -- <file_name>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Revert: Undo a commit by creating a new commit\",\n        \"tip\": \"git revert <commit-ish>\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Reset: Discard commits, advised for private branch\",\n        \"tip\": \"git reset <commit-ish>\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Reword the previous commit message\",\n        \"tip\": \"git commit -v --amend\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"See commit history for just the current branch\",\n        \"tip\": \"git cherry -v master\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Amend author.\",\n        \"tip\": \"git commit --amend --author='Author Name <email@address.com>'\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Reset author, after author has been changed in the global config.\",\n        \"tip\": \"git commit --amend --reset-author --no-edit\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Changing a remote's URL\",\n        \"tip\": \"git remote set-url origin <URL>\",\n        \"category\": \"Remotes\"\n    },\n    {\n        \"title\": \"Get list of all remote references\",\n        \"tip\": \"git remote\",\n        \"alternatives\": [\n            \"git remote show\"\n        ],\n        \"category\": \"Remotes\"\n    },\n    {\n        \"title\": \"Get list of all local and remote branches\",\n        \"tip\": \"git branch -a\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Get only remote branches\",\n        \"tip\": \"git branch -r\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Stage parts of a changed file, instead of the entire file\",\n        \"tip\": \"git add -p\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Get git bash completion\",\n        \"tip\": \"curl -L http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrc\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"What changed since two weeks?\",\n        \"tip\": \"git log --no-merges --raw --since='2 weeks ago'\",\n        \"alternatives\": [\n            \"git whatchanged --since='2 weeks ago'\"\n        ],\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"See all commits made since forking from master\",\n        \"tip\": \"git log --no-merges --stat --reverse master..\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Pick commits across branches using cherry-pick\",\n        \"tip\": \"git checkout <branch-name> && git cherry-pick <commit-ish>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Find out branches containing commit-hash\",\n        \"tip\": \"git branch -a --contains <commit-ish>\",\n        \"alternatives\": [\n            \"git branch --contains <commit-ish>\"\n        ],\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Git Aliases\",\n        \"tip\": \"git config --global alias.<handle> <command> \\ngit config --global alias.st status\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Saving current state of tracked files without committing\",\n        \"tip\": \"git stash\",\n        \"alternatives\": [\n            \"git stash push\"\n        ],\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Saving current state of unstaged changes to tracked files\",\n        \"tip\": \"git stash -k\",\n        \"alternatives\": [\n            \"git stash --keep-index\",\n            \"git stash push --keep-index\"\n        ],\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Saving current state including untracked files\",\n        \"tip\": \"git stash -u\",\n        \"alternatives\": [\n            \"git stash push -u\",\n            \"git stash push --include-untracked\"\n        ],\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Saving current state with message\",\n        \"tip\": \"git stash push -m <message>\",\n        \"alternatives\": [\n            \"git stash push --message <message>\"\n        ],\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Saving current state of all files (ignored, untracked, and tracked)\",\n        \"tip\": \"git stash -a\",\n        \"alternatives\": [\n            \"git stash --all\",\n            \"git stash push --all\"\n        ],\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Show list of all saved stashes\",\n        \"tip\": \"git stash list\",\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Show the contents of any stash in patch form\",\n        \"tip\": \"git stash show -p <stash@{n}>\",\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Apply any stash without deleting from the stashed list\",\n        \"tip\": \"git stash apply <stash@{n}>\",\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Apply last stashed state and delete it from stashed list\",\n        \"tip\": \"git stash pop\",\n        \"alternatives\": [\n            \"git stash apply stash@{0} && git stash drop stash@{0}\"\n        ],\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Delete all stored stashes\",\n        \"tip\": \"git stash clear\",\n        \"alternatives\": [\n            \"git stash drop <stash@{n}>\"\n        ],\n        \"category\": \"Stashing\"\n    },\n    {\n        \"title\": \"Grab a single file from a stash\",\n        \"tip\": \"git checkout <stash@{n}> -- <file_path>\",\n        \"alternatives\": [\n            \"git checkout stash@{0} -- <file_path>\"\n        ],\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Show all tracked files\",\n        \"tip\": \"git ls-files -t\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Show all untracked files\",\n        \"tip\": \"git ls-files --others\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Show all ignored files\",\n        \"tip\": \"git ls-files --others -i --exclude-standard\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Create new working tree from a repository (git 2.5)\",\n        \"tip\": \"git worktree add -b <branch-name> <path> <start-point>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Create new working tree from HEAD state\",\n        \"tip\": \"git worktree add --detach <path> HEAD\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Untrack files without deleting\",\n        \"tip\": \"git rm --cached <file_path>\",\n        \"alternatives\": [\n            \"git rm --cached -r <directory_path>\"\n        ],\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Before deleting untracked files/directory, do a dry run to get the list of these files/directories\",\n        \"tip\": \"git clean -n\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Forcefully remove untracked files\",\n        \"tip\": \"git clean -f\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Forcefully remove untracked directory\",\n        \"tip\": \"git clean -f -d\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Update all the submodules\",\n        \"tip\": \"git submodule foreach git pull\",\n        \"alternatives\": [\n            \"git submodule update --init --recursive\",\n            \"git submodule update --remote\"\n        ],\n        \"category\": \"Submodules and Subtrees\"\n    },\n    {\n        \"title\": \"Show all commits in the current branch yet to be merged to master\",\n        \"tip\": \"git cherry -v master\",\n        \"alternatives\": [\n            \"git cherry -v master <branch-to-be-merged>\"\n        ],\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Rename a branch\",\n        \"tip\": \"git branch -m <new-branch-name>\",\n        \"alternatives\": [\n            \"git branch -m [<old-branch-name>] <new-branch-name>\"\n        ],\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Rebases 'feature' to 'master' and merges it in to master \",\n        \"tip\": \"git rebase master feature && git checkout master && git merge -\",\n        \"category\": \"Merging and Rebasing\"\n    },\n    {\n        \"title\": \"Archive the `master` branch\",\n        \"tip\": \"git archive master --format=zip --output=master.zip\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Modify previous commit without modifying the commit message\",\n        \"tip\": \"git add --all && git commit --amend --no-edit\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Prunes references to remove branches that have been deleted in the remote.\",\n        \"tip\": \"git fetch -p\",\n        \"alternatives\": [\n            \"git remote prune origin\"\n        ],\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Delete local branches that has been squash and merged in the remote.\",\n        \"tip\": \"git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Retrieve the commit hash of the initial revision.\",\n        \"tip\": \" git rev-list --reverse HEAD | head -1\",\n        \"alternatives\": [\n            \"git rev-list --max-parents=0 HEAD\",\n            \"git log --pretty=oneline | tail -1 | cut -c 1-40\",\n            \"git log --pretty=oneline --reverse | head -1 | cut -c 1-40\"\n        ],\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Visualize the version tree.\",\n        \"tip\": \"git log --pretty=oneline --graph --decorate --all\",\n        \"alternatives\": [\n            \"gitk --all\",\n            \"git log --graph --pretty=format:'%C(auto) %h | %s | %an | %ar%d'\"\n        ],\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Visualize the tree including commits that are only referenced from reflogs\",\n        \"tip\": \"git log --graph --decorate --oneline $(git rev-list --walk-reflogs --all)\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Deploying git tracked subfolder to gh-pages\",\n        \"tip\": \"git subtree push --prefix subfolder_name origin gh-pages\",\n        \"alternatives\": [\n            \"git subtree push --prefix subfolder_name origin branch_name\"\n        ],\n        \"category\": \"Submodules and Subtrees\"\n    },\n    {\n        \"title\": \"Adding a project to repo using subtree\",\n        \"tip\": \"git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master\",\n        \"category\": \"Submodules and Subtrees\"\n    },\n    {\n        \"title\": \"Get latest changes in your repo for a linked project using subtree\",\n        \"tip\": \"git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master\",\n        \"category\": \"Submodules and Subtrees\"\n    },\n    {\n        \"title\": \"Export a branch with history to a file.\",\n        \"tip\": \"git bundle create <file> <branch-name>\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Import from a bundle\",\n        \"tip\": \"git clone repo.bundle <repo-dir> -b <branch-name>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Get the name of current branch.\",\n        \"tip\": \"git rev-parse --abbrev-ref HEAD\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Ignore one file on commit (e.g. Changelog).\",\n        \"tip\": \"git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Stash changes before rebasing\",\n        \"tip\": \"git rebase --autostash\",\n        \"category\": \"Merging and Rebasing\"\n    },\n    {\n        \"title\": \"Fetch pull request by ID to a local branch\",\n        \"tip\": \"git fetch origin pull/<id>/head:<branch-name>\",\n        \"alternatives\": [\n            \"git pull origin pull/<id>/head:<branch-name>\"\n        ],\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Show the most recent tag on the current branch.\",\n        \"tip\": \"git describe --tags --abbrev=0\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Show inline word diff.\",\n        \"tip\": \"git diff --word-diff\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Show changes using common diff tools.\",\n        \"tip\": \"git difftool [-t <tool>] <commit1> <commit2> <path>\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Don\\u2019t consider changes for tracked file.\",\n        \"tip\": \"git update-index --assume-unchanged <file_name>\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Undo assume-unchanged.\",\n        \"tip\": \"git update-index --no-assume-unchanged <file_name>\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Clean the files from `.gitignore`.\",\n        \"tip\": \"git clean -X -f\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Restore deleted file.\",\n        \"tip\": \"git checkout <deleting_commit> -- <file_path>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Restore file to a specific commit-hash\",\n        \"tip\": \"git checkout <commit-ish> -- <file_path>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Always rebase instead of merge on pull.\",\n        \"tip\": \"git config --global pull.rebase true\",\n        \"alternatives\": [\n            \"#git < 1.7.9\\ngit config --global branch.autosetuprebase always\"\n        ],\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"List all the alias and configs.\",\n        \"tip\": \"git config --list\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Make git case sensitive.\",\n        \"tip\": \"git config --global core.ignorecase false\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Add custom editors.\",\n        \"tip\": \"git config --global core.editor '$EDITOR'\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Auto correct typos.\",\n        \"tip\": \"git config --global help.autocorrect 1\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Check if the change was a part of a release.\",\n        \"tip\": \"git name-rev --name-only <SHA-1>\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Dry run. (any command that supports dry-run flag should do.)\",\n        \"tip\": \"git clean -fd --dry-run\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Marks your commit as a fix of a previous commit.\",\n        \"tip\": \"git commit --fixup <SHA-1>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Squash fixup commits normal commits.\",\n        \"tip\": \"git rebase -i --autosquash\",\n        \"category\": \"Merging and Rebasing\"\n    },\n    {\n        \"title\": \"Skip staging area during commit.\",\n        \"tip\": \"git commit --only <file_path>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Interactive staging.\",\n        \"tip\": \"git add -i\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"List ignored files.\",\n        \"tip\": \"git check-ignore *\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Status of ignored files.\",\n        \"tip\": \"git status --ignored\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Commits in Branch1 that are not in Branch2\",\n        \"tip\": \"git log Branch1 ^Branch2\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"List n last commits\",\n        \"tip\": \"git log -<n>\",\n        \"alternatives\": [\n            \"git log -n <n>\"\n        ],\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Reuse recorded resolution, record and reuse previous conflicts resolutions.\",\n        \"tip\": \"git config --global rerere.enabled 1\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Open all conflicted files in an editor.\",\n        \"tip\": \"git diff --name-only | uniq | xargs $EDITOR\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Count unpacked number of objects and their disk consumption.\",\n        \"tip\": \"git count-objects --human-readable\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Prune all unreachable objects from the object database.\",\n        \"tip\": \"git gc --prune=now --aggressive\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Instantly browse your working repository in gitweb.\",\n        \"tip\": \"git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"View the GPG signatures in the commit log\",\n        \"tip\": \"git log --show-signature\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Remove entry in the global config.\",\n        \"tip\": \"git config --global --unset <entry-name>\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Checkout a new branch without any history\",\n        \"tip\": \"git checkout --orphan <branch_name>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Extract file from another branch.\",\n        \"tip\": \"git show <branch_name>:<file_name>\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"List only the root and merge commits.\",\n        \"tip\": \"git log --first-parent\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Change previous two commits with an interactive rebase.\",\n        \"tip\": \"git rebase --interactive HEAD~2\",\n        \"category\": \"Merging and Rebasing\"\n    },\n    {\n        \"title\": \"List all branch is WIP\",\n        \"tip\": \"git checkout master && git branch --no-merged\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Find guilty with binary search\",\n        \"tip\": \"git bisect start                    # Search start \\ngit bisect bad                      # Set point to bad commit \\ngit bisect good v2.6.13-rc2         # Set point to good commit|tag \\ngit bisect bad                      # Say current state is bad \\ngit bisect good                     # Say current state is good \\ngit bisect reset                    # Finish search \\n\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Bypass pre-commit and commit-msg githooks\",\n        \"tip\": \"git commit --no-verify\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"List commits and changes to a specific file (even through renaming)\",\n        \"tip\": \"git log --follow -p -- <file_path>\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Clone a single branch\",\n        \"tip\": \"git clone -b <branch-name> --single-branch https://github.com/user/repo.git\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Create and switch new branch\",\n        \"tip\": \"git checkout -b <branch-name>\",\n        \"alternatives\": [\n            \"git branch <branch-name> && git checkout <branch-name>\",\n            \"git switch -c <branch-name>\"\n        ],\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Ignore file mode changes on commits\",\n        \"tip\": \"git config core.fileMode false\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Turn off git colored terminal output\",\n        \"tip\": \"git config --global color.ui false\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Specific color settings\",\n        \"tip\": \"git config --global <specific command e.g branch, diff> <true, false or always>\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Show all local branches ordered by recent commits\",\n        \"tip\": \"git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Find lines matching the pattern (regex or string) in tracked files\",\n        \"tip\": \"git grep --heading --line-number 'foo bar'\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Clone a shallow copy of a repository\",\n        \"tip\": \"git clone https://github.com/user/repo.git --depth 1\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Search Commit log across all branches for given text\",\n        \"tip\": \"git log --all --grep='<given-text>'\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Get first commit in a branch (from master)\",\n        \"tip\": \"git log --oneline master..<branch-name> | tail -1\",\n        \"alternatives\": [\n            \"git log --reverse master..<branch-name> | head -6\"\n        ],\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Unstaging Staged file\",\n        \"tip\": \"git reset HEAD <file-name>\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Force push to Remote Repository\",\n        \"tip\": \"git push -f <remote-name> <branch-name>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Adding Remote name\",\n        \"tip\": \"git remote add <remote-nickname> <remote-url>\",\n        \"category\": \"Remotes\"\n    },\n    {\n        \"title\": \"List all currently configured remotes\",\n        \"tip\": \"git remote -v\",\n        \"category\": \"Remotes\"\n    },\n    {\n        \"title\": \"Show the author, time and last revision made to each line of a given file\",\n        \"tip\": \"git blame <file-name>\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Group commits by authors and title\",\n        \"tip\": \"git shortlog\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Forced push but still ensure you don't overwrite other's work\",\n        \"tip\": \"git push --force-with-lease <remote-name> <branch-name>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Show how many lines does an author contribute\",\n        \"tip\": \"git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \\\"added lines: %s removed lines: %s total lines: %s\\n\\\", add, subs, loc }' -\",\n        \"alternatives\": [\n            \"git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \\\"added lines: %s, removed lines: %s, total lines: %s\\n\\\", add, subs, loc }' - # on Mac OSX\"\n        ],\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Revert: Reverting an entire merge\",\n        \"tip\": \"git revert -m 1 <commit-ish>\",\n        \"category\": \"Undoing Changes\"\n    },\n    {\n        \"title\": \"Number of commits in a branch\",\n        \"tip\": \"git rev-list --count <branch-name>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Alias: git undo\",\n        \"tip\": \"git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Add object notes\",\n        \"tip\": \"git notes add -m 'Note on the previous commit....'\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Show all the git-notes\",\n        \"tip\": \"git log --show-notes='*'\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Apply commit from another repository\",\n        \"tip\": \"git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | git am -3 -k\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Specific fetch reference\",\n        \"tip\": \"git fetch origin master:refs/remotes/origin/mymaster\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Find common ancestor of two branches\",\n        \"tip\": \"git merge-base <branch-name> <other-branch-name>\",\n        \"category\": \"Merging and Rebasing\"\n    },\n    {\n        \"title\": \"List unpushed git commits\",\n        \"tip\": \"git log --branches --not --remotes\",\n        \"alternatives\": [\n            \"git log @{u}..\",\n            \"git cherry -v\"\n        ],\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Add everything, but whitespace changes\",\n        \"tip\": \"git diff --ignore-all-space | git apply --cached\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Edit [local/global] git config\",\n        \"tip\": \"git config [--global] --edit\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"blame on certain range\",\n        \"tip\": \"git blame -L <start>,<end>\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Show a Git logical variable.\",\n        \"tip\": \"git var -l | <variable>\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Preformatted patch file.\",\n        \"tip\": \"git format-patch -M upstream..topic\",\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Get the repo name.\",\n        \"tip\": \"git rev-parse --show-toplevel\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"logs between date range\",\n        \"tip\": \"git log --since='FEB 1 2017' --until='FEB 14 2017'\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Exclude author from logs\",\n        \"tip\": \"git log --perl-regexp --author='^((?!excluded-author-regex).*)$'\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Generates a summary of pending changes\",\n        \"tip\": \"git request-pull v1.0 https://git.ko.xz/project master:for-linus\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"List references in a remote repository\",\n        \"tip\": \"git ls-remote git://git.kernel.org/pub/scm/git/git.git\",\n        \"category\": \"Remotes\"\n    },\n    {\n        \"title\": \"Backup untracked files.\",\n        \"tip\": \"git ls-files --others -i --exclude-standard | xargs zip untracked.zip\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"List all git aliases\",\n        \"tip\": \"git config -l | grep alias | sed 's/^alias\\\\.//g'\",\n        \"alternatives\": [\n            \"git config -l | grep alias | cut -d '.' -f 2\"\n        ],\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Show git status short\",\n        \"tip\": \"git status --short --branch\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Checkout a commit prior to a day ago\",\n        \"tip\": \"git checkout master@{yesterday}\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Push the current branch to the same name on the remote repository\",\n        \"tip\": \"git push origin HEAD\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Push a new local branch to remote repository and track\",\n        \"tip\": \"git push -u origin <branch_name>\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Change a branch base\",\n        \"tip\": \"git rebase --onto <new_base> <old_base>\",\n        \"category\": \"Merging and Rebasing\"\n    },\n    {\n        \"title\": \"Use SSH instead of HTTPs for remotes\",\n        \"tip\": \"git config --global url.'git@github.com:'.insteadOf 'https://github.com/'\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Update a submodule to the latest commit\",\n        \"tip\": \"cd <path-to-submodule>\\ngit pull origin <branch>\\ncd <root-of-your-main-project>\\ngit add <path-to-submodule>\\ngit commit -m \\\"submodule updated\\\"\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Prevent auto replacing LF with CRLF\",\n        \"tip\": \"git config --global core.autocrlf false\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Refresh the list of remote branches\",\n        \"tip\": \"git remote update origin --prune\",\n        \"category\": \"Remotes\"\n    },\n    {\n        \"title\": \"View expanded details of changes in last commit\",\n        \"tip\": \"git show\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Send a collection of patches as emails\",\n        \"tip\": \"git send-email [<options>] <file|directory>\\u2026\\n\\ngit send-email [<options>] <format-patch options>\",\n        \"category\": \"Miscellaneous\"\n    },\n    {\n        \"title\": \"Edit config for each level\",\n        \"tip\": \"git config --edit --system\\n\\ngit config --edit --global\\n\\ngit config --edit --local\",\n        \"category\": \"Setup and Config\"\n    },\n    {\n        \"title\": \"Visualize each position of HEAD in the last 30 days\",\n        \"tip\": \"git reflog\",\n        \"category\": \"Log and History\"\n    },\n    {\n        \"title\": \"Duplicating a repository\",\n        \"tip\": \"git clone --bare https://github.com/exampleuser/old-repository.git\\n\\ngit push --mirror https://github.com/exampleuser/new-repository.git\",\n        \"category\": \"Basic Operations\"\n    },\n    {\n        \"title\": \"Switch to a branch (modern alternative to checkout)\",\n        \"tip\": \"git switch <branch-name>\",\n        \"alternatives\": [\n            \"git switch -c <new-branch-name>\"\n        ],\n        \"category\": \"Branching\"\n    },\n    {\n        \"title\": \"Restore file (modern alternative to reset/checkout --)\",\n        \"tip\": \"git restore <file-name>\",\n        \"alternatives\": [\n            \"git restore --staged <file-name>\"\n        ],\n        \"category\": \"Undoing Changes\"\n    }\n]"
  }
]