+3

Tổng hợp các câu lệnh GIT dị ít dùng GIT#2

Git Bash Commands Cheat Sheet

Inspect & Compare

Traking Path Changes

  1. git ls-files # List all files tracked by Git
  2. git blame <file> # Show who changed what in a file
  3. git bisect # Find the commit that introduced a bug
  4. git reflog # Show a log of all local commits
  5. git cat-file -p <commit> # Display the content of a commit object
  6. git rev-parse <ref> # Get the SHA-1 hash of a reference
  7. git fsck # Verify the integrity of the repository
  8. git gc # Clean up unnecessary files and optimize the repository

Remove, and Rename

  1. git rm <file> # Remove a file from the repository and working directory
  2. git mv <old-name> <new-name> # Rename or move a file
  3. git clean -f # Remove untracked files from the working directory
  4. git clean -fd # Remove untracked files and directories from the working directory

Tags

  1. git tag # List tags
  2. git tag <tag-name> # Create a lightweight tag
  3. git tag -a <tag-name> -m "<message>" # Create an annotated tag
  4. git push origin <tag-name> # Push a tag to the remote repository
  5. git tag -d <tag-name> # Delete a local tag
  6. git push origin --delete <tag-name> # Delete a remote tag
  7. git tag --contains <commit> # Find tags containing a specific commit
  8. git describe # Describe the most recent tag and commit

Advanced Commands

  1. git submodule add <repository> <path> # Add a Git submodule
  2. git submodule init # Initialize Git submodules
  3. git submodule update # Update Git submodules
  4. git submodule foreach <command> # Execute a command in all submodules
  5. git grep <pattern> # Search for a pattern in the repository
  6. git log -S"<pattern>" # Search for commits that added or removed a pattern
  7. git archive --format=zip --output=<output-file> <branch> # Create a zip archive of a branch
  8. git shortlog # Summarize commit logs by author
  9. git log --graph --decorate --oneline # Display commit history as a graph
  10. git rev-list --count <ref> # Count the number of commits in a branch
  11. git commit --amend # Modify the last commit
  12. git commit --amend -m "<new-message>" # Modify the last commit message
  13. git reflog expire --expire=now --all # Remove all reflog entries
  14. git rev-parse --show-toplevel # Show the root directory of the repository
  15. git config --global alias.<alias-name> '<git-command>' # Create a Git alias
  16. git help <command> # Show help for a Git command

All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí