Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

OT - git related bourne-like shell functions

by parv (Priest)
on Nov 02, 2012 at 12:48 UTC ( #1001960=perlmeditation: print w/replies, xml ) Need Help??

Not really a meditation this is but more of shell scripting code contribution related to git ...

# Some git commands for use in bourne-like shells; # some could be aliases. gshow_old_branch() { local old old=$( git branch ) printf "## Moving from %s\n" "${old}" >&2 } gmerge() { git mergetool } gcon() { git rebase --continue } gskip() { git rebase --skip } gabort() { git rebase --abort } ghard() { git reset --hard $@ } gwhere() { git branch } ghelp() { git "${1}" --help } gadjust() { git rebase -i $@ } grephrase() { git commit --amend } gcd() { case $# in 0 ) printf "Need a branch to change to\n" >&2 return 1 ;; * ) git checkout "$1" ;; esac } gupdate() { gshow_old_branch git checkout master \ && git pull --rebase } gplop() { case $# in 0 | 1 ) printf "Need a branch to change and a branch to rebase on\n" >&2 exit 1 ;; * ) ;; esac set +x local in="$1" local out="$2" git checkout "$out" && git rebase "$in" [ $? -eq 0 ] || return case $# in 2 ) ;; * ) shift shift set -- $out $@ set +x gplop $@ ;; esac } glastmerge() { git ci -a -m '# (merge with previous)' \ && git rebase -i HEAD^^ } gpick() { for m in $@ do git cherry-pick "${m}" || break done } gitm() { date='last 5 months' gitk --all --date-order --since="$date" $@ } gdiff() { git diff $@ } gpatch() { git diff --no-color $@ } gmovetag() { local tag pos case $# in 0 | 1 ) printf "Need both an tag to move and the new location.\n" >&1 exit 1 ;; * ) tag="${1}" pos="${2}" ;; esac set +x git tag -d "${tag}" git tag -a "${tag}" "${pos}" -m 'Reset mark.' set +x }

Let me know please if comments may be needed for some of the functions.

Replies are listed 'Best First'.
Re: OT - git related (bourne-like shell) functions
by Tanktalus (Canon) on Nov 04, 2012 at 14:56 UTC

    For a lot of these, I would suggest using bash with the git bash-completion scripts (one for git and one for the git prompt). Then you can tab-complete most of these. The advantage is that you subconsciously learn/remember all the underlying commands which makes looking up the man pages easier, but also makes it easier to move from machine to machine where the other machine may not have as much environment set up. I often log in to coworkers' machines to help them out with stuff, and many of these commands look like things I'd help them with, so learning the actual commands is still handy.

Re: OT - git related (bourne-like shell) functions
by daxim (Chaplain) on Nov 05, 2012 at 16:16 UTC
    The simple shell functions that perform no logic can also be done with git's built-in aliases feature. Feel free to copy from my config file.
      Indeed, but then I would have things in multiple places (git and/or shell aliases); that is the reason that simple things are with the complex ones.
Re: OT - git related (bourne-like shell) functions (cmd.exe/doskey)
by Anonymous Monk on Nov 02, 2012 at 14:13 UTC
    FWIW, has some similar things, the win32 equivalent of which might be
    doskey gs=git status $* doskey ga=git add $* doskey gb=git branch $* doskey gc=git commit $* doskey gd=git diff $* doskey go=git checkout $* doskey gk=start "" gitk --all $* doskey gx=gitx --all $* doskey gh=git log --pretty=format:"%h %ad | %s%d [%an]" --graph --dat +e=short doskey got=git $* doskey get=git $*

    A more readable fork of that tutorial is

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1001960]
[LanX]: yep heard the same origin story
[Your Mother]: I like it. I tottered on going into hucksterism because I feel like the world deserves it.
[LanX]: he ... we have a movement here called Anti-Germans based on this
[Corion]: Your Mother: I think that's because (in the west) the Nazi-Germans are recognized as universally evil. Of course, you could do some number games to calculate other measures of evil than "historic losers of second world war" to come up with other evils:)
[Corion]: I've heard "Troll" described as the new Punk, and in a way, it can be as destructive as living the Punk lifestyle, and you don't have to sit out in the cold...
[LanX]: Anti-Germans
[LanX]: Socrates was a Troll
[Your Mother]: It's very, very dangerous... Thinking that a group is intrinsically evil... buries the fact that all humans can be so deep that it starts to become likely they will be.
[Your Mother]: LanX++
[Corion]: (also the "troll for trolls sake" could seen be much like the "punk for punks beer")

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (17)
As of 2018-03-19 13:43 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.