Git Alias
· One min read
Code
[alias]
branch-name = "!git rev-parse --abbrev-ref HEAD"
n = checkout -b
c = checkout
s = status
p = "!git push -u origin $(git branch-name)"
undo = reset HEAD~1
Description
branch-name: Retrieves the current branch name usinggit rev-parse --abbrev-ref HEAD. This alias is particularly useful for thepcommand, as it automatically includes the current branch name when pushing to the remote repository.n: A shortcut to create a new branch withcheckout -b.c: A simplified alias forcheckout, used to switch between branches.s: Short forstatus, displays the current working directory status.p: Pushes the current branch to the remote repository usinggit push -u originand automatically includes the branch name.undo: A quick command to undo the last commit by resetting the HEAD pointer to the previous commit.