mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2026-01-11 21:36:00 +01:00
feat(git): add create and checkout branch as new gitf cb case (#102)
Reviewed-on: https://codeberg.org/vlw/dotfiles/pulls/102
This commit is contained in:
parent
39f4227c06
commit
ae3b0ec4e8
1 changed files with 19 additions and 4 deletions
|
|
@ -162,18 +162,33 @@ gitf () {
|
|||
gitf
|
||||
;;
|
||||
|
||||
# Checkout [and create] a git branch (defaults to "master")
|
||||
# Checkout a git branch (defaults to "master")
|
||||
"b")
|
||||
local branch="${2:-master}"
|
||||
|
||||
if git show-ref --verify --quiet refs/heads/"$branch"; then
|
||||
git checkout $branch
|
||||
if ! git show-ref --verify --quiet refs/heads/"$branch"; then
|
||||
gitf
|
||||
echo ""
|
||||
echo -e "\e[0;91mNo such branch '$branch'\e[0m"
|
||||
return 0
|
||||
fi
|
||||
|
||||
git checkout $branch
|
||||
gitf
|
||||
;;
|
||||
|
||||
# Checkout [and create] a git branch (defaults to "master")
|
||||
"cb")
|
||||
local branch="${2:-master}"
|
||||
|
||||
# Checkout existing branch
|
||||
if git show-ref --verify --quiet refs/heads/"$branch"; then
|
||||
gitf b $branch
|
||||
return 0
|
||||
fi
|
||||
|
||||
git checkout -b $branch
|
||||
gitf
|
||||
gitf b $branch
|
||||
;;
|
||||
|
||||
# Pull current branch from a remote (defaults to "origin"). "d" for download.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue