Compare commits

..

34 Commits

Author SHA1 Message Date
c6d4bcff4f Fix color output in aliases on macOS 2025-12-17 15:53:42 +00:00
61ebacc776 Also include ./local if present 2025-01-20 21:42:36 +00:00
ba4cf18cd2 Ignore credentials file if it exists 2024-04-19 14:49:06 +01:00
75b88f3a59 Add compile_commands.json to excludes file 2024-03-09 12:50:15 +00:00
8a3b86753a Sort git branch output by descending committer date 2024-01-30 13:54:00 +00:00
7fb360690d Add git-sync command to fetch from a list of repos 2023-04-20 13:37:57 +01:00
d5ae3dbfc8 Make (un)publish alias remote configurable
Add the `publish.remote` option to enable the remote to publish to
configurable rather than hard-coded in the alias.
2022-12-15 11:50:46 +00:00
753778c632 Set the default branch name for main 2022-09-09 22:52:13 +01:00
2d898122c3 Add XDG like dirs to excludes 2022-04-20 15:35:31 +01:00
c2e3d6065c Don't blindly set vim as editor
This is now deferred to `GIT_EDITOR` environment variable.
2022-02-26 17:24:20 +00:00
0514ccd0c3 Add recent alias to show 10 most recent branches 2022-01-12 18:04:50 +00:00
2615350bb8 Move main.yaml to tasks.yaml 2021-11-19 22:07:35 +00:00
e2218750fa Use https URL for git-issue pip package 2021-11-05 15:21:00 +00:00
2473202cd8 Start using Ansible for config management 2021-11-05 14:31:09 +00:00
781fff16d6 Add uncommit alias 2021-08-03 14:17:09 +01:00
1f87dfa8a5 Add root alias to show the top level git directory 2021-07-14 11:22:42 +01:00
561ea3bc1a Add .vim to excludes file 2021-06-18 13:44:52 +01:00
02a239e1d8 Colorize error messages 2021-04-26 14:59:51 +01:00
24b44903b5 Drop lastpass-cli 2021-02-17 22:12:20 +00:00
95c1550d02 Always ignore .DS_Store files 2021-01-06 17:48:26 +00:00
4cd036401c Set config pull.rebase to false to quiet warnings 2020-08-22 10:50:00 +01:00
347b263fd6 Set up merge tool and improve diffs
* Use vimdiff2 for git mergetool
* Use patience diff algorithm for diff and merge
2020-07-02 15:56:12 +01:00
9d77e3e058 Setup side-by-side diffs using vim
Set `git difftool` to use `vimdiff` to display diffs, when multiple
files are in the diff, don't prompt when exiting `vimdiff` before
viewing the next file diffs.
2020-06-09 12:13:25 +01:00
75117da7cb Add git-issue for installation 2020-04-24 10:58:17 +01:00
46f722b2a7 Remove -a from save alias
Allow more control over which changes are saved when using the save
alias by removing the `-a` flag.
2019-10-11 11:06:03 +01:00
2e5cf11730 Disable verbose in commit messages 2019-05-01 20:05:05 +01:00
2f16349e97 Add tracking alias to show tracking branch 2019-03-24 15:15:06 +00:00
26ecd94fb4 Update README with latest alias descriptions 2019-02-15 17:07:32 +00:00
17a5a0e946 Add local alias for listing non-remote branches 2019-02-15 14:05:49 +00:00
225fe9a243 Simplify tree alias & split onto multiple lines 2019-02-15 14:05:05 +00:00
854df7bc22 Add unamend alias to help reversing an amend
* `unamend` applies the diff from a previous `commit --amend` to the
working tree to make it easy to undo an accidental amend.
* Removed `last` alias, use `checkout -` instead
* Rename `name` alias to `refname` to be less ambiguous
2019-02-06 14:12:40 +00:00
e63768ba22 Add alias to show the files touched in a commit 2019-01-17 17:48:43 +00:00
9511061155 Remove 3 way vimdiff 2018-12-14 18:32:23 +00:00
71ef3dfba5 Update _git-changes to complete more branch names 2018-10-23 18:00:36 +01:00
8 changed files with 99 additions and 30 deletions

View File

@@ -1,9 +0,0 @@
---
- location: ~/.config/git
- brew:
- lastpass-cli
- symlink:
- {src: config, dst: ~/.gitconfig}
- {src: _git-changes, dst: ~/.local/share/zsh/site-functions/_git-changes}
- repo:
- git@code.infektor.net:benie/config.git

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
credentials
local

View File

@@ -8,15 +8,16 @@ rather than remembering the plumbing term of a specific command.
* `abandon` abandons all local changes leave a clean repository.
* `unstage` unstage staged changes, shorthand for `git reset -q HEAD --`.
* `amend` amends the last commit, shorthand for `git commit --amend`.
* `unamend` applies a negative diff of the last `git commit --amend`.
* `fixup` prepare to fixup a commit, shorthand for `git commit --fixup`.
* `squash` prepare to squash a commit, shorthand for `git commit --squash`.
* `prepare` prepare a branch for merging into another, shorthand for
`git rebase --interactive --fork-point`.
* `list` list local branches, a shorthand for `git branch`.
* `local` list local branches which don't have remote tracking branches.
* `create` creates a new branch, shorthand for `git checkout -b`.
* `delete` deletes an existing branch, shorthand for `git branch -D`.
* `name` the name of the current branch.
* `last` the name of the last branch checked out before the current branch.
* `refname` the name of the current branch.
* `publish` push and set the tracking branch of a local branch to origin,
shorthand for `git push -u origin <branch>`.
* `unpublish` delete a remote branch, shorthand for `git push origin :<branch>`.
@@ -25,6 +26,7 @@ rather than remembering the plumbing term of a specific command.
* `changes` compare the list of commits on the local branch to another branch,
e.g. when on a feature branch `git changes master` lists the commits which are
not present on the master branch.
* `touched` lists the files which were touched by a selected commit.
* `save` like pushing to the stash but attached to the current branch, shorthand
for `git commit -am "temp!"`.
* `load` like popping from the stash but attached to the current branch, if

View File

@@ -1,6 +1,8 @@
#compdef git-changes
#description Compare changes on this branch with another.
_arguments '1: :(`__git_branch_names` `__git_remote_branch_names` `__git_remote_branch_names_noprefix`'
_alternative \
'branches::__git_branch_names' \
'remote-branches::__git_remote_branch_names'
# vim: ft=zsh

66
config
View File

@@ -1,62 +1,94 @@
# vim: ft=gitconfig
[alias]
root = rev-parse --show-toplevel
abandon = !git reset --hard HEAD && git clean -d -f
uncommit = !git reset --soft HEAD~1 && git unstage
unstage = reset -q HEAD --
amend = commit --amend
unamend = !git diff $(git reflog -2 | \
awk \"{print \\$1}\" | \
sed -e ':a' -e 'N' -e '$!ba' -e 's/\\n/../g') | \
git apply - 2> /dev/null || \
echo "\\\\033[31merror:\\\\033[39m last commit was not amended"
fixup = commit --fixup
squash = commit --squash
prepare = rebase -i --fork-point
list = branch
local = !git branch -vv | \
cut -c 3- | \
awk '$3 !~/\\[/ { print $1 }'
recent = !git reflog show --pretty=format:'%gs ~ %gd' --date=relative | \
grep 'checkout:' | \
grep -oE '[^ ]+ ~ .*' | \
awk -F~ '!seen[$1]++' | \
head -n 10 | \
awk -F ' ~ HEAD@{' '{printf(\" %s \\033[33m%s\\033[0m\\n\", $1, substr($2, 1, length($2)-1))}'
create = checkout -b
delete = branch -D
name = rev-parse --abbrev-ref HEAD
last = !sh -c 'git reflog | grep \" checkout: moving from\" | head -n 1 | awk \"{ print \\$6 }\"'
refname = rev-parse --abbrev-ref HEAD
publish = !git push -u origin `git name`
unpublish = !git push -u origin :`git name`
publish = !git push -u `git config --get publish.remote || echo origin` `git refname`
unpublish = !git push -u `git config --get publish.remote || echo origin` :`git refname`
force = push --force-with-lease
changes = !sh -c 'git log --oneline $1..' --
tree = log --graph --abbrev-commit --oneline --decorate \
--format=format:'%C(yellow)%h%C(reset) %C(blue)%aD%C(reset) %C(green)(%ar)%C(reset)%C(bold)%d%C(reset)%n %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
touched = diff-tree --no-commit-id --name-only -r
tree = log --graph --format=format:'%C(yellow)%h%C(reset) \
%C(blue)%aD%C(reset) %C(green)(%ar)%C(reset)%C(bold)%d%C(reset)%n \
%C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
tracking = rev-parse --abbrev-ref --symbolic-full-name @{u}
save = commit -am "temp!"
save = commit -m "temp!"
load = !sh -c '[ \"temp!\" = \"`git show --format=%s --no-patch`\" ] && \
git reset --mixed HEAD~ || echo \"error: commit subject is not: temp!\"'
[commit]
verbose = true
git reset --mixed HEAD~ || echo \"\\033[31merror:\\033[39m commit subject is not: temp!\"'
[core]
editor = vim
excludesfile = ~/.config/git/excludes
[init]
defaultBranch = main
[branch]
sort = -committerdate
[fetch]
prune = true
[help]
autocorrect = -1
[merge]
tool = vimdiff
conflictstyle = diff3
prompt = false
[pager]
status = true
[push]
default = simple
[pull]
rebase = false
[rebase]
autoSquash = true
[user]
useConfigOnly = true
[diff]
tool = vimdiff
algorithm = patience
[difftool]
prompt = false
[merge]
tool = vimdiff2
algorithm = patience
[mergetool]
prompt = false
[include]
path = ~/.config/private/gitconfig
path = ~/.config/work/gitconfig
path = ~/.config/git/local

View File

@@ -1,3 +1,9 @@
.local
.DS_Store
.cache
.config
.enter
.exit
.local
.share
.vim
compile_commands.json

23
git-sync Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env zsh
autoload -U colors && colors
git_sync=${GIT_SYNC:-~/.config/git-sync}
if [ ! -f "$git_sync" ]; then
echo "$fg[yellow]warning:${reset_color} sync list does not exist: $git_sync"
exit 0
fi
local repos=($(cat $git_sync))
if [ ${#repos[@]} = 0 ]; then
echo "$fg[yellow]warning:${reset_color} sync list is empty: $git_sync"
exit 0
fi
for repo in $repos; do
print -P "$fg[cyan]synchronizing: $repo${reset_color}"
repo="${repo/#\~/$HOME}"
git -C "$repo" fetch
done

11
tasks.yaml Normal file
View File

@@ -0,0 +1,11 @@
---
- name: git create symbolic links
file:
state: link
src: '{{item.src}}'
dest: '{{item.dest}}'
with_items:
- src: ~/.config/git/_git-changes
dest: ~/.local/share/zsh/site-functions/_git-changes
- src: ~/.config/git/git-sync
dest: ~/.local/bin/git-sync