Skip to content

Instantly share code, notes, and snippets.

@srehaider
Created January 18, 2023 20:32
Show Gist options
  • Save srehaider/340e240fdcbaa08fe3e4846f29105d60 to your computer and use it in GitHub Desktop.
Save srehaider/340e240fdcbaa08fe3e4846f29105d60 to your computer and use it in GitHub Desktop.
alias.com !git checkout "$(basename $(git symbolic-ref refs/remotes/origin/HEAD))" && git pull
alias.co checkout
alias.st status
alias.br branch
alias.cb checkout -b
alias.cm !git checkout "$(basename $(git symbolic-ref refs/remotes/origin/HEAD))"
alias.update !git fetch && git rebase "origin/$(basename $(git symbolic-ref refs/remotes/origin/HEAD))"
@rehan-pp
Copy link

Added force update fupdate and undo aliases.

[alias]
	st = status -sb
	lol = log --oneline
	cm = commit -m # Commit changes with new message
	ca = commit --amend -C HEAD # Ameend last commit with new changes without changing message
	cam = commit --amend -m # Change the message of last commit
	lc = config --global -l # List all configs
	br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
	s = status
	co = checkout
	cb = checkout -b
	del = branch -D
	p = push origin HEAD
	fp = push -f origin HEAD
	undo = reset --hard ORIG_HEAD # Undo reset, rebase and merge
	mb = !basename $(git symbolic-ref refs/remotes/origin/HEAD) # Get main branch
	com = !git checkout $(git mb) && git pull # Checkout main branch and pull latest changes
	# alias with command line argument and default value, append # to ignore extra parameters
	update = "!git fetch && git rebase origin/${1:-$(git mb)} #" # Rebase the current branch with the latest main branch or given branch name
	fupdate = "!git fetch && git rebase --force-rebase origin/${1:-$(git mb)} #" # Force rebase the current branch with the latest main branch or given branch name
	tb = checkout - # Toggle between recent branches

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