Add configuration for git
- Add .config/git/config + Define aliases + Configure default behavior in various situations + Add user information with signing key - Add .config/git/commit_msg_template.txt - Add .config/git/ignore - Integrate `git` aliases into the shell
This commit is contained in:
parent
3017a7bdec
commit
721c2fd905
21 changed files with 1122 additions and 66 deletions
28
.local/bin/git-checkout-first-existing-branch
Executable file
28
.local/bin/git-checkout-first-existing-branch
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Check out the first of the given branches that exists,
|
||||
# looking at both local branches and the ones on `origin`
|
||||
#
|
||||
# Usage: git checkout-first-existing-branch <branch> [<branch> ...]
|
||||
|
||||
set -eu
|
||||
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: git checkout-first-existing-branch <branch> [<branch> ...]" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
for _branch in "$@"; do
|
||||
|
||||
if git show-ref --verify --quiet "refs/heads/$_branch" \
|
||||
|| git show-ref --verify --quiet "refs/remotes/origin/$_branch"; then
|
||||
exec git checkout "$_branch"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
echo "None of these branches exists: $*" >&2
|
||||
exit 1
|
||||
Loading…
Reference in a new issue