revert single file
git checkout HEAD -- my-file.txt
reset git
git reset --hard HEAD^
Basic Tag Command
Fetch semua tag dari git server
git fetch --tag
List tag di local
git tag -l
Hapus tag di local
#hapus single tag
git tag -d v1.0
#hapus tag batch all
git tag -l | xargs git tag -d
Hapus tag di remote
#hapus single tag remote
git push -d origin v1.0
#hapus tag batch, hapus tag awalan v1*
git push -d origin $(git tag -l "v1*")
#remove all tag
git tag -l | xargs -n 1 git push --delete origin
remove all unused branch
#we keep master, development and staging
git branch --merged | grep -v "\*" | grep -v "master" | grep -v "development" | grep -v "main" | grep -v "staging" | xargs -n 1 git branch -d
#source https://stackoverflow.com/a/32166469
remove branch regex
git branch | grep "<pattern>" | xargs git branch -D
#check current branch
git rev-parse --abbrev-ref HEAD
#check latest commit message
git log --pretty=format:"%s" |head -1
git log |head -6 #for more info
#get latest tag
git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1)
git --no-pager log --decorate=short --pretty=oneline -n1