diff options
| author | nsfisis <nsfisis@gmail.com> | 2022-06-18 12:06:29 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2022-06-18 12:06:29 +0900 |
| commit | dea21e780cc009929b00f85c55a7bd54a77512ff (patch) | |
| tree | 866a35a3b12a9fb05c74068680972e3ba547697e | |
| parent | 1b58012464070bcf788e57835fb7c574349019fb (diff) | |
| download | dotfiles-dea21e780cc009929b00f85c55a7bd54a77512ff.tar.gz dotfiles-dea21e780cc009929b00f85c55a7bd54a77512ff.tar.zst dotfiles-dea21e780cc009929b00f85c55a7bd54a77512ff.zip | |
git: git checkout => git switch/restore
| -rw-r--r-- | .config/git/config | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/.config/git/config b/.config/git/config index ab4642f..fb7a629 100644 --- a/.config/git/config +++ b/.config/git/config @@ -62,26 +62,32 @@ fixup = commit --fixup amend = commit --amend --no-edit clone1 = clone --depth=1 - co = checkout - cob = checkout -b - com = "!__fn() { \ + sw = "!__fn() { \ + if [[ \"$1\" == origin/* || \"$1\" == upstream/* ]]; then \ + git switch -d \"$@\"; \ + else \ + git switch \"$@\"; \ + fi; \ + }; __fn" + swc = switch -b + swm = "!__fn() { \ if git rev-parse --verify --quiet main > /dev/null 2>&1; then \ - git checkout main \"$@\"; \ + git switch main \"$@\"; \ elif git rev-parse --verify --quiet origin/main > /dev/null 2>&1; then \ - git checkout origin/main \"$@\"; \ + git switch -d origin/main \"$@\"; \ elif git rev-parse --verify --quiet master > /dev/null 2>&1; then \ - git checkout master \"$@\"; \ + git switch master \"$@\"; \ elif git rev-parse --verify --quiet origin/master > /dev/null 2>&1; then \ - git checkout origin/master \"$@\"; \ + git switch -d origin/master \"$@\"; \ else \ echo 'error: no branch found' >&2; \ fi; \ }; __fn" - cod = "!__fn() { \ + swd = "!__fn() { \ if git rev-parse --verify --quiet develop > /dev/null 2>&1; then \ - git checkout develop \"$@\"; \ + git switch develop \"$@\"; \ elif git rev-parse --verify --quiet origin/develop > /dev/null 2>&1; then \ - git checkout origin/develop \"$@\"; \ + git switch -d origin/develop \"$@\"; \ else \ echo 'error: no branch found' >&2; \ fi; \ @@ -116,6 +122,7 @@ ri = rebase -i rid = rebase -i develop rc = "!GIT_EDITOR=true git rebase --continue" + re = restore rep = restore -p m = "!__fn() { \ if [[ \"$1\" == --abort ]]; then \ |
