Compare commits

...

4 Commits

Author SHA1 Message Date
Morten Olsen
3c2be26cac improved git flow 2026-01-02 10:25:53 +01:00
Morten Olsen
760f8584cf improved git flow 2025-12-29 21:37:09 +01:00
Morten Olsen
7eb837a068 improved git flow 2025-12-29 21:32:07 +01:00
Morten Olsen
225b91b5d6 improved git flow 2025-12-29 21:27:28 +01:00
3 changed files with 62 additions and 9 deletions

View File

@@ -25,6 +25,7 @@ in
# Password management
"1password"
"1password-cli"
"bitwarden"
# Terminal & Development
"ghostty"

View File

@@ -125,6 +125,57 @@ in
autoSetupRemote = true;
};
# Rebase settings
rebase = {
autoStash = true;
updateRefs = true;
};
# Rerere (Reuse Recorded Resolution) - automatically reuse conflict resolutions
rerere = {
enabled = true;
};
# Color settings
color = {
ui = "auto";
branch = "auto";
diff = "auto";
status = "auto";
};
# Diff settings
diff = {
compactionHeuristic = true;
algorithm = "patience";
colorMoved = "default";
};
# Merge settings
merge = {
conflictStyle = "zdiff3";
};
# Fetch settings
fetch = {
prune = true;
showForcedUpdates = true;
};
# Advice settings (disable annoying messages)
advice = {
detachedHead = false;
statusHints = true;
addIgnoredFile = false;
};
# Blame settings
blame = {
colorLines = true;
markUnblamables = true;
markUnblamableLines = true;
};
# GPG/SSH signing settings
gpg = {
format = "ssh";
@@ -197,9 +248,8 @@ in
append = "commit --amend --no-edit";
# Stage all and amend to last commit
fix = "!git add . && git commit --amend --no-edit";
# Stage all, amend, rebase, and force push with lease
sync = "!f() { git add . && git commit --amend --no-edit && git rebase origin/$(git rev-parse --abbrev-ref HEAD) && git push --force-with-lease; }; f";
fck = "!f() { git add . && git commit --amend --no-edit && git rebase origin/$(git rev-parse --abbrev-ref HEAD) && git push --force-with-lease; }; f";
# Stage all, amend, and safely force push with lease and force-if-includes
fck = "!f() { git add . && git commit --amend --no-edit && git push --force-with-lease --force-if-includes; }; f";
# Stage all, commit with message, and push
save = "!f() { git add --all && git commit -m \"$*\" && git push; }; f";
@@ -208,10 +258,10 @@ in
# Interactive fixup: pick commit with fzf, stage all, create fixup
fix-commit = "!f() { commit=$(git log --oneline --color=always | fzf --ansi --height 40% | awk '{print $1}'); [ -n \"$commit\" ] && git add . && git commit --fixup=\"$commit\"; }; f";
apply-fixes = "!f() { upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream} 2>/dev/null); if [ -n \"$upstream\" ]; then git rebase -i --autosquash \"$upstream\"; elif git show-ref --verify --quiet refs/remotes/origin/main; then git rebase -i --autosquash origin/main; elif git show-ref --verify --quiet refs/remotes/origin/master; then git rebase -i --autosquash origin/master; else echo \"No upstream branch found. Usage: git squash-fixups <base-branch>\"; fi; }; f";
apply-fixes = "!f() { upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream} 2>/dev/null); if [ -n \"$upstream\" ]; then git rebase -i --autosquash \"$upstream\"; elif git show-ref --verify --quiet refs/remotes/origin/main; then git rebase -i --autosquash origin/main; elif git show-ref --verify --quiet refs/remotes/origin/master; then git rebase -i --autosquash origin/master; elif git show-ref --verify --quiet refs/heads/main; then git rebase -i --autosquash main; elif git show-ref --verify --quiet refs/heads/master; then git rebase -i --autosquash master; else first_commit=$(git rev-list --reverse HEAD | head -1); if [ -n \"$first_commit\" ]; then base=$(git rev-parse \"$first_commit^\" 2>/dev/null); if [ -n \"$base\" ] && [ \"$base\" != \"$first_commit\" ]; then git rebase -i --autosquash \"$base\"; else echo \"Could not determine base. Usage: git apply-fixes <base-branch>\"; fi; else echo \"No base branch found. Usage: git apply-fixes <base-branch>\"; fi; fi; }; f";
# Squash all commits unique to current branch (auto-detects default branch)
cleanup = "!f() { default=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; if git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then base=$(git merge-base HEAD \"origin/$default\"); git rebase -i \"$base\"; else echo \"Could not find default branch (main/master). Usage: git squash-all <base-branch>\"; fi; }; f";
squash-all = "!f() { default=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; if git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then base=$(git merge-base HEAD \"origin/$default\"); git rebase -i \"$base\"; else echo \"Could not find default branch (main/master). Usage: git squash-all <base-branch>\"; fi; }; f";
cleanup = "!f() { default=$(git remote show origin 2>/dev/null | sed -n '/HEAD branch/s/.*: //p' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; if git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then base=$(git merge-base HEAD \"origin/$default\"); git rebase -i \"$base\"; else echo \"Could not find default branch (main/master). Usage: git squash-all <base-branch>\"; fi; }; f";
squash-all = "!f() { default=$(git remote show origin 2>/dev/null | sed -n '/HEAD branch/s/.*: //p' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; if git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then base=$(git merge-base HEAD \"origin/$default\"); git rebase -i \"$base\"; else echo \"Could not find default branch (main/master). Usage: git squash-all <base-branch>\"; fi; }; f";
# Staging aliases
# =====
@@ -235,11 +285,11 @@ in
# Fetch from all remotes
fetch-all = "fetch --all";
# Pull latest changes
pull-latest = "!f() { default=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; git pull origin \"$default\"; }; f";
pull-latest = "!f() { default=$(git remote show origin 2>/dev/null | sed -n '/HEAD branch/s/.*: //p' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; git pull origin \"$default\"; }; f";
# Push and set upstream
push-new = "!f() { git push -u origin $(git rev-parse --abbrev-ref HEAD); }; f";
# Update from main/master (rebase)
update-from-main = "!f() { default=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; git fetch origin && git rebase \"origin/$default\"; }; f";
update-from-main = "!f() { default=$(git remote show origin 2>/dev/null | sed -n '/HEAD branch/s/.*: //p' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; git fetch origin && git rebase \"origin/$default\"; }; f";
# Stash aliases
# =====
@@ -255,7 +305,7 @@ in
# =====
# Create new feature branch from main/master
new-feature = "!f() { default=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; git fetch origin && git checkout -b \"$1\" \"origin/$default\"; }; f";
new-feature = "!f() { default=$(git remote show origin 2>/dev/null | sed -n '/HEAD branch/s/.*: //p' || echo \"main\"); if ! git show-ref --verify --quiet \"refs/remotes/origin/$default\"; then default=\"master\"; fi; git fetch origin && git checkout -b \"$1\" \"origin/$default\"; }; f";
# Compare current branch with another branch
compare = "!f() { git diff \"$1\"..HEAD; }; f";

View File

@@ -115,6 +115,7 @@
age # Modern encryption tool
sops # Secrets management
rustscan # The Modern Port Scanner. Find ports quickly (3 seconds at its fastest). nmap alternative.
bitwarden-cli
# ========================================================================
# Miscellaneous Tools
@@ -130,6 +131,7 @@
mob
zsh-fast-syntax-highlighting
jellyfin-tui
mpv
# ========================================================================
# Nix Tools