Skip to content

Instantly share code, notes, and snippets.

@lakinmindfire
Created May 7, 2024 06:39
Show Gist options
  • Save lakinmindfire/572a0bfecc8a42644344cc3fbc21c5a2 to your computer and use it in GitHub Desktop.
Save lakinmindfire/572a0bfecc8a42644344cc3fbc21c5a2 to your computer and use it in GitHub Desktop.
15 Useful Git Commands
  1. ๐ ๐ข๐ญ ๐ฅ๐จ๐  --๐š๐ฎ๐ญ๐ก๐จ๐ซ="<๐š๐ฎ๐ญ๐ก๐จ๐ซ>": Shows commits authored by the specified author.

  2. ๐ ๐ข๐ญ ๐๐ข๐Ÿ๐Ÿ --๐ง๐š๐ฆ๐ž-๐จ๐ง๐ฅ๐ฒ: Shows only the names of files that have differences between two commits or branches.

  3. ๐ ๐ข๐ญ ๐ฉ๐ซ๐ฎ๐ง๐ž: Removes unreachable objects and refs from the local repository.

  4. ๐ ๐ข๐ญ ๐๐ข๐Ÿ๐Ÿ --๐ฌ๐ญ๐š๐ ๐ž๐: Show the differences between the staging area and the last commit.

  5. ๐ ๐ข๐ญ ๐ซ๐ž๐Ÿ๐ฅ๐จ๐ : Shows a log of all the changes made to the refs (branches, tags) in the repository.

  6. ๐ ๐ข๐ญ ๐ซ๐ž๐ฌ๐ญ๐จ๐ซ๐ž <๐Ÿ๐ข๐ฅ๐ž_๐ง๐š๐ฆ๐ž>: Restores the specified file to its state in the last commit, discarding any changes made to the file in the working directory.

  7. ๐ ๐ข๐ญ ๐›๐ข๐ฌ๐ž๐œ๐ญ: Use binary search to find the commit that introduced a bug.

  8. ๐ ๐ข๐ญ ๐›๐ฅ๐š๐ฆ๐ž <๐Ÿ๐ข๐ฅ๐ž_๐ง๐š๐ฆ๐ž>: Shows the author and commit details for each line of a file.

  9. ๐ ๐ข๐ญ ๐ฌ๐ก๐จ๐ซ๐ญ๐ฅ๐จ๐ : Summarizes the git log output, grouping commits by author.

  10. ๐ ๐ข๐ญ ๐ฅ๐จ๐  -๐’ <๐ฌ๐ญ๐ซ๐ข๐ง๐ >: Finds commits that added or removed the given string.

  11. ๐ ๐ข๐ญ ๐ฆ๐ž๐ซ๐ ๐ž --๐ฌ๐ช๐ฎ๐š๐ฌ๐ก <๐›๐ซ๐š๐ง๐œ๐ก_๐ง๐š๐ฆ๐ž>: Merge a branch, but condense all changes into a single commit.

  12. ๐ ๐ข๐ญ ๐Ÿ๐ž๐ญ๐œ๐ก --๐ฉ๐ซ๐ฎ๐ง๐ž: Fetch changes from a remote repository and clean up deleted remote branches.

  13. ๐ ๐ข๐ญ ๐ฌ๐ก๐จ๐ฐ <๐œ๐จ๐ฆ๐ฆ๐ข๐ญ>:<๐Ÿ๐ข๐ฅ๐ž๐ง๐š๐ฆ๐ž>: Show the file as it was at the specified commit.

  14. ๐ ๐ข๐ญ ๐ง๐จ๐ญ๐ž๐ฌ: Allows you to add notes to individual commits without modifying the commit message.

  15. ๐ ๐ข๐ญ ๐œ๐ฅ๐ž๐š๐ง: Removes untracked files from the working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment