-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitconfig
More file actions
54 lines (54 loc) · 3.64 KB
/
Copy pathgitconfig
File metadata and controls
54 lines (54 loc) · 3.64 KB
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
54
[user]
name = Kevin Cheng
email = kevin.cheng.97@gmail.com
[alias]
co = checkout
br = branch
cp = cherry-pick
st = status
cl = clone
ci = commit
last = log -1
diff = diff --word-diff
dc = diff --cached
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
le = log --oneline --decorate
fl = log -u
dl = "!git ll -1"
dlc = diff --cached HEAD^
dr = "!f() { git diff "$1"^.."$1"; }; f"
lc = "!f() { git ll "$1"^.."$1"; }; f"
diffr = "!f() { git diff "$1"^.."$1"; }; f"
f = "!git ls-files | grep -i"
r = reset
r1 = reset HEAD^
r2 = reset HEAD^^
rh = reset --hard
rh1 = reset HEAD^ --hard
rh2 = reset HEAD^^ --hard
logtree = log --graph --oneline --decorate --all
push = !git fetch origin && git rebase origin/$(git rev-parse --abbrev-ref HEAD) && git push
sync-branch = "!f() { \n # Parse arguments\n mode=\"rebase\"; # default\n use_stash=false;\n while [ $# -gt 0 ]; do\n case $1 in\n --merge)\n mode=\"merge\"\n shift\n ;;\n --rebase)\n mode=\"rebase\"\n shift\n ;;\n --stash)\n use_stash=true\n shift\n ;;\n *)\n echo \"Unknown option: $1\"\n echo \"Usage: git sync-branch [--merge|--rebase] [--stash]\"\n exit 1\n ;;\n esac\n done;\n \n current_branch=$(git branch --show-current);\n if [ \"$current_branch\" = \"main\" ]; then\n echo \"Error: Cannot run this command on main branch\";\n exit 1;\n fi;\n \n echo \"Current branch: $current_branch\";\n echo \"Mode: $mode\";\n \n # Check if we have uncommitted changes and stash them\n stash_created=false;\n if git diff --quiet && git diff --cached --quiet; then\n echo \"No uncommitted changes to stash\";\n else\n if [ \"$use_stash\" = true ]; then\n echo \"Stashing uncommitted changes...\";\n git stash push -m \"sync-branch auto-stash\" --include-untracked;\n stash_created=true;\n else\n echo \"Warning: You have uncommitted changes. Use --stash flag to automatically stash them.\";\n echo \"Uncommitted changes will remain in your working directory.\";\n fi;\n fi;\n \n echo \"Switching to main and pulling latest changes...\";\n git checkout main &&\n git pull &&\n echo \"Switching back to $current_branch...\" &&\n git checkout \"$current_branch\" &&\n \n # Pop stash immediately after returning to feature branch\n if [ \"$stash_created\" = true ]; then\n echo \"Restoring stashed changes...\";\n git stash pop;\n fi &&\n \n if [ \"$mode\" = \"rebase\" ]; then\n echo \"Rebasing $current_branch onto main...\" &&\n git rebase main;\n else\n echo \"Merging main into $current_branch...\" &&\n git merge main;\n fi &&\n \n echo \"Force pushing $current_branch...\" &&\n git push -f;\n}; f"
reset-hard = !echo \"ERROR: git reset --hard is disabled for safety. Use git reset --soft or git reset --mixed instead.\" && exit 1
[push]
default = upstream
autoSetupRemote = true
[color]
ui = true
[core]
pager = cat
excludesfile = ~/.gitignore_global
autocrlf = input
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[pull]
rebase = true
[checkout]
defaultRemote = origin