Skip to content

Instantly share code, notes, and snippets.

@carpusherw
Last active December 8, 2023 04:34
Show Gist options
  • Save carpusherw/371a9153d697ab1dd8f8163f69f89dcf to your computer and use it in GitHub Desktop.
Save carpusherw/371a9153d697ab1dd8f8163f69f89dcf to your computer and use it in GitHub Desktop.
Git setup

git

ssh-keygen -t rsa -b 4096 -C "carpusher.wu@gofreight.com"

eval "$(ssh-agent -s)"
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub

ssh -T git@github.com

git config --global user.email "carpusher.wu@gofreight.com"
git config --global user.name "carpusher"
git config --global push.default current
git config --global core.pager 'less -x1,5'
git config --global core.editor code --wait
# git config --global core.autocrlf true

git config --global alias.br branch
git config --global alias.st status
git config --global alias.l "log --decorate --oneline --graph"
git config --global alias.l1 "log -1 --oneline"
git config --global alias.ln '!f() { git log -$1 --oneline; }; f'
git config --global alias.pu pull
git config --global alias.p push
git config --global alias.pf "push -f"
git config --global alias.a add
git config --global alias.aa "add ."
git config --global alias.cm commit
git config --global alias.cmm '!f() { jira_case=$(git branch | sed -n -e '"'"'s/^\* .*\/\([a-zA-Z]*-[0-9]*\).*/\1/p'"'"'); commit_msg=$(echo "$jira_case $1" | sed -e '"'"'s/^[[:space:]]*//'"'"'); git commit -m "$commit_msg"; }; f'
git config --global alias.cmcr '!f() { jira_case=$(git branch | sed -n -e '"'"'s/^\* .*\/\([a-zA-Z]*-[0-9]*\).*/\1/p'"'"');git commit -m "$jira_case Code review (To be Squashed)"; }; f'
git config --global alias.co checkout
git config --global alias.nb "checkout -b"
git config --global alias.d diff
git config --global alias.dc "diff --cached"
git config --global alias.dh "diff HEAD^"
git config --global alias.cp cherry-pick
git config --global alias.cpc "cherry-pick --continue"
git config --global alias.cpa "cherry-pick --abort"
git config --global alias.rs "restore"
git config --global alias.rss "restore --staged"
git config --global alias.rh "reset HEAD"
git config --global alias.rhn '!git reset HEAD~$1 & :'
git config --global alias.rcmm '!f() { jira_case=$(git branch | sed -n -e '"'"'s/^\* .*\/\([a-zA-Z]*-[0-9]*\).*/\1/p'"'"'); commit_msg=$(echo "$jira_case $2" | sed -e '"'"'s/^[[:space:]]*//'"'"'); git reset --soft HEAD~$1; git commit -m "$commit_msg"; }; f'
git config --global alias.sq '!f() { count="$(($1-1))"; if [ "$count" -lt "0" ]; then count=0; fi; message=$(git show -s --format=%B HEAD~$count); git reset --soft HEAD~$(($count+1)); git commit -m "$message"; }; f'
git config --global alias.sth stash
git config --global alias.stp "stash pop"
git config --global alias.rb rebase
git config --global alias.rbc "rebase --continue"
git config --global alias.rba "rebase --abort"
git config --global alias.debug '!GIT_TRACE=1 git'

git config --global gpg.program gpg2
git config --global user.signingkey <signing-subkey-id>
git config --global commit.gpgsign true

gh

gh auth login
gh alias set pco 'pr checkout'
gh alias set pc 'pr create --web --fill'
gh alias set pl 'pr list'
gh alias set pv 'pr view'
gh alias set pst 'pr status'
gh alias set pm 'pr merge --rebase --delete-branch'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment