Một vài câu lệnh git nâng cao

1. General

Bash
# Hard reset a branch feature to a commit (= git checkout + git reset)
git branch -f <branch-name> <commit-hash>

2. git log

Bash
# Search by commit message (subject and body) in git log
git log --grep="<commit message>"

3. git reflog

Bash
# Search by commit subject (not body) in git reflog
git reflog --grep-reflog="<commit subject>"

# Show timestamps in ISO format
git reflog --grep-reflog="<commit subject>" --date=iso

# Limit output to the last 5 matching entries
git reflog --grep-reflog="<commit subject>" -n 5

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment