Commit 21ab6af1 authored by nimrod's avatar nimrod
Browse files

Some git scripts cleanup.

Mainly about the default branch, fetching and rebasing on it.

- A nicer default-branch alias (without a shell).
- Address if running git-master on the default branch.
- Make git-master a script since it became too complex.
- Address if running git-remaster on the default branch.
- Make git-remaster a script sine it became too complex.
- Remove git-rerebase (I should just use git pull --rebase).
- Change git-ff to use a non-hardcoded default branch.
parent fabc83c6
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -9,15 +9,14 @@
    cdiff = diff --cached
    cleaan = clean -dX
    cleaaan = clean -dx
    default-branch = !git rev-parse  --abbrev-ref origin/HEAD | cut -d/ -f2
    default-branch = name-rev --name-only origin/HEAD
    dif = diff --color-words
    empty-commit = commit --allow-empty
	exec = "!${SHELL:-/bin/sh} -ic "
    ff = merge --no-edit --ff-only master
    ff = merge --no-edit --ff-only origin/HEAD
    fixup = !cd "${GIT_PREFIX:-$PWD}" && git commit --fixup $(git last-commit)
    forget = reset HEAD^
    iec = commit --allow-empty --only --message \"Initial empty commit.\"
    master = !git fetch --progress --tags "${1:-origin}" "$(git default-branch):$(git default-branch)"
    merg = merge --no-edit
    pop = stash pop
    posh = push --set-upstream origin HEAD
@@ -25,8 +24,6 @@
    Pull = pull --progress --ff --tags
    pull-force = !git fetch && git reset --hard "$(git tracking)"
    pushes = !git remote | xargs -n1 git push
    remaster = !git master && git autorebase "$(git default-branch)"
    rerebase = !git autorebase "$(git tracking)"
    retry = !cd "${GIT_PREFIX:-$PWD}" && git amend --no-edit . && git shove
    root = rev-parse --show-toplevel
    serve-git = daemon --reuseaddr --verbose --base-path=. --export-all ./.git
+17 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

# Update the default branch without checking out that branch (unless we're
# already on the default branch, then just run git Pull. Accepts 1 paramter,
# the remote name (defaults to origin).

default_branch="$(git default-branch)"
current_branch="$(git branch --show-current)"
remote="${1:-origin}"

if [ "$default_branch" = "$current_branch" ]
then
    git Pull
else
    git fetch --progress --tags "$remote" "$default_branch:$default_branch"
fi
+17 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

# Update the default branch using git-remaster, then rebase the current branch
# on the default branch (unless we're already on the default branch, then we're
# just run git Pull).

default_branch="$(git default-branch)"
current_branch="$(git branch --show-current)"

if [ "$default_branch" = "$current_branch" ]
then
    git Pull
else
    git master
    git autorebase "$default_branch"
fi