Skip to content

Instantly share code, notes, and snippets.

@waterlink
Last active December 26, 2015 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waterlink/7167227 to your computer and use it in GitHub Desktop.
Save waterlink/7167227 to your computer and use it in GitHub Desktop.
my git workflow
#!/bin/bash
alias gf="git fetch"
function gwco {
number="$1"
# all branches | get origin/number_* | remove remotes/ | remove origin/ | 1st line| strip
branch=$(git branch -a | grep -F "origin/${number}_" | sed 's/remotes\///' | sed 's/origin\///' | head -1 | awk '{print $1}')
git checkout "${branch}"
}
alias gwcom="git checkout origin/master"
alias gwrbim="git rebase -i origin/master"
alias gpu="git push -u"
alias gcob="git checkout -b"
alias gpf="git push -f"
alias ga.="git add ."
function gwcob {
branch="$*"
branch=$(echo "$branch" | sed 's/[^a-z0-9_]/_/ig')
git checkout -b "$branch" || git checkout "$branch"
}
function load_gitlab_config {
gitlab_conf="$(git rev-parse --show-toplevel)/.gitlab"
[[ -f "${gitlab_conf}" ]] && source ${gitlab_conf}
}
function glco {
issue_id=$1
load_gitlab_config
issue_title=$(curl -k "${gitlab_host}/api/v3/projects/${gitlab_project_id}/issues.json?private_token=${gitlab_private_token}" 2>/dev/null | python -c "
import json,sys;
for issue in json.load(sys.stdin):
if issue['iid'] == ${issue_id}:
print issue['title']
")
gwcob "${issue_id}/${issue_title}"
}
# ....
. ~/.scripts/git-workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment