mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2026-01-12 05:45:59 +01:00
feat(git): add create and checkout branch as new gitf case
This commit is contained in:
parent
612fc10935
commit
d98f532dc6
1 changed files with 19 additions and 4 deletions
|
|
@ -162,18 +162,33 @@ gitf () {
|
||||||
gitf
|
gitf
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Checkout [and create] a git branch (defaults to "master")
|
# Checkout a git branch (defaults to "master")
|
||||||
"b")
|
"b")
|
||||||
local branch="${2:-master}"
|
local branch="${2:-master}"
|
||||||
|
|
||||||
if git show-ref --verify --quiet refs/heads/"$branch"; then
|
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
|
git checkout $branch
|
||||||
gitf
|
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
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout -b $branch
|
git checkout -b $branch
|
||||||
gitf
|
gitf b $branch
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Pull current branch from a remote (defaults to "origin"). "d" for download.
|
# Pull current branch from a remote (defaults to "origin"). "d" for download.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue