-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitconfig
53 lines (52 loc) · 2.6 KB
/
.gitconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[user]
name = laudebugs
email = laudebugs@gmail.com
[alias]
# Pass in a commit Message, This will stage ALL the changed files and commit with the provided commit message and sign the commit (-S)
ac = !git add -A && git commit -S -m
# Filter changed files based on a string and ONLY stage files that contain that substring in the diff
add-string = "!sh -c \"git diff -G '$1' --name-only | xargs git add\" -"
c = !git commit -S -m
# This clones a git repository into bare repository
clone-bare = !git clone --bare
# For each the comma-delimited x of provided input a,b,c,...,n run git fetch origin x:x
fetch-some = "!f() { IFS=','; for b in $1; do git fetch origin $b:$b; done; unset IFS; }; f"
# For each branch y in a git bare repo, run git fetch origin y:y
fetch-all = "!git for-each-ref --format='%(refname:short)' refs/heads/ | while read branch; do git fetch origin $branch:$branch; done"
# List the last n checked out branches in a git repository
last-checked = !git reflog | grep -i 'checkout: moving' | head -n
# lists the "parent" branch for a given branch
# Source: https://stackoverflow.com/questions/3161204/how-to-find-the-nearest-parent-of-a-git-branch
parent = "!git show-branch | grep '*' | grep -v \"$(git rev-parse --abbrev-ref HEAD)\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//' #"
# Sets up the upstream and pushes the local branch to the remote origin
push-origin = !git push --set-upstream origin \"$(git rev-parse --abbrev-ref HEAD)\"
# This resets the last commit made
uncommit = reset --soft HEAD~1
# This git alias takes two commands, the first being the new branch name, the second being the base branch
# The new worktree will be located at the path that matches the branch name and based on the base branch
# Git Worktree Documentation: https://git-scm.com/docs/git-worktree
# The Command `git rev-parse --git-common-dir ensures that worktree paths are always generated from the root of the bare repo
wa = "!sh -c \"cd $(git rev-parse --git-common-dir) && git worktree add --no-track -b '$1' '$1' '$2'\" -"
# Adds all the files in the current directory and commits with the provided commit message
adc = !git add -A && git commit -S -m
# checkout a new branch
cb = checkout -b
adc = !git add -A :!pnpm-lock.yaml && git commit -S -m
# checkout a new branch
cb = checkout -b
# Cherry Pick shortcut
cp = cherry-pick
# List the worktrees
wl = worktree list
[core]
editor = code --wait
[commit]
gpgsign = true
[gpg]
program = gpg
[credential]
helper = store
[checkout]
defaultRemote = origin
[push]
autoSetupRemote = true