-
Notifications
You must be signed in to change notification settings - Fork 115
/
.gitaliases
49 lines (45 loc) · 2.1 KB
/
.gitaliases
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
[alias]
#########################
# Needed base functions #
#########################
# Get the current branch name (not so useful in itself, but used in other aliases)
branch-name = !"git rev-parse --abbrev-ref HEAD"
# Creates given branch based on develop and deletes the one original one with the same name
create-with-delete = !"f() { git checkout develop && git branch -d $@ && git checkout -b $@; }; f"
####################
# Simple Shortcuts #
####################
# Go to the branch with given name
go = "checkout"
# Gets the given remote branch locally and set to track it
get = "checkout -t"
# Go back to develop branch
return = "checkout develop"
# Removes the last commit
undo-commit = reset --soft HEAD~1
####################
# Primary Commands #
####################
# Creates given branch based on master and checks it out. Just a shortcut of git checkout -b
work = !"f() { git return && git checkout -b $@; }; f"
# Refresh the current branch from upstream
refresh = !"f() { git pull upstream $(git branch-name) && git push; }; f"
# Push the current branch to the remote "origin", and set it to track the upstream branch
publish = !"git push -u origin $(git branch-name)"
# Delete the remote version of the current branch
unpublish = "!git push origin :$(git branch-name)"
# Resets the current branch to origin
reset-to-origin = !"git reset --hard origin/$(git branch-name)"
# Recreates current branch based on develop
recreate = !"f() { git create-with-delete $(git branch-name); }; f"
# Remove all branches that got already merged
tidy = !"git return && git refresh && git fetch --all -p && git branch -vv | grep ': gone]' | awk '{ print $1 }' | xargs -n 1 git branch -D"
###########
# Helpers #
###########
# Lists all existing aliases
list-aliases = "!git config -l | grep alias | cut -c 7-"
# Create a Test branch based on develop
test = !"git work Test"
# Deletes the test branch and goes back to develop
test-finished = !"git return && git branch -D Test"