Skip to content

git-alias

Published: at 下午10:53
[alias]
        w=      watch
        g=      goto

        tree=   log --graph --pretty=tformat:'%C(auto)%h%d %C(reset)%m %C(blue)%an %C(green)%cd %C(reset)%s' --date='format:%m-%d %a %H:%M' --abbrev-commit --all --date-order
        t=      log --graph --pretty=tformat:'%C(auto)%h%d %C(reset)%m %C(blue)%an %C(green)%cd %C(reset)%s' --date='format:%m-%d %a %H:%M' --abbrev-commit --all --date-order
        tree-branch=    log --graph --pretty=tformat:'%C(auto)%h%d %C(reset)%m %C(blue)%an %C(green)%cd %C(reset)%s' --date='format:%m-%d %a %H:%M' --abbrev-commit
        tb=     log --graph --pretty=tformat:'%C(auto)%h%d %C(reset)%m %C(blue)%an %C(green)%cd %C(reset)%s' --date='format:%m-%d %a %H:%M' --abbrev-commit

        rg=     reflog --pretty=tformat:'%gd %C(auto)%h %C(blue)%an %C(green)%cs %C(auto)%gs%d'

        c=      commit --allow-empty -m
        cc=     commit
        c-=     commit --amend --allow-empty
        commit-with-add=        !git add . && git commit -m a
        ca=     !git add . && git commit -m a
        ca-=    !git add . && git commit --amend --allow-empty -m a
        cf=     clean -df

        a=      add
        add-pick=       add -p
        ap=     add -p
        add-all=        add -A .
        aa=     add -A .
        add-untracked=  !git add --intent-to-add `git status -s | grep '??' | sed 's/^??\\s//g'`
        an=     !git add --intent-to-add `git status -s | grep '??' | sed 's/^??\\s//g'`
        au=     add-unmerged

        o=      checkout
        checkout-force= checkout -f
        of=     checkout -f
        ot=     checkout --track
        om=     checkout --merge
        op=     checkout -p
        ob=     checkout HEAD~1
        obb=    checkout HEAD~2
        obbb=   checkout HEAD~3
        obbbb=  checkout HEAD~4
        obbbbb= checkout HEAD~5
        obbbbbb=        checkout HEAD~6
        obbbbbbb=       checkout HEAD~7
        o-=     checkout HEAD@{1}
        o--=    checkout HEAD@{2}
        o---=   checkout HEAD@{3}
        o----=  checkout HEAD@{4}
        o-----= checkout HEAD@{5}
        o------=        checkout HEAD@{6}
        o-------=       checkout HEAD@{7}

        r=      reset
        rp=     reset -p
        reset-hard=     reset --hard
        rh=     reset --hard
        reset-back=     reset HEAD^
        rb=     reset HEAD~1
        rbb=    reset HEAD~2
        rbbb=   reset HEAD~3
        rbbbb=  reset HEAD~4
        rbbbbb= reset HEAD~5
        rbbbbbb=        reset HEAD~6
        rbbbbbbb=       reset HEAD~7
        r-=     reset HEAD@{1}
        r--=    reset HEAD@{2}
        r---=   reset HEAD@{3}
        r----=  reset HEAD@{4}
        r-----= reset HEAD@{5}
        r------=        reset HEAD@{6}
        r-------=       reset HEAD@{7}
        reset-back-hard=        reset --hard HEAD^
        rbh=    reset --hard HEAD~1
        rbbh=   reset --hard HEAD~2
        rbbbh=  reset --hard HEAD~3
        rbbbbh= reset --hard HEAD~4
        rbbbbbh=        reset --hard HEAD~5
        rbbbbbbh=       reset --hard HEAD~6
        rbbbbbbbh=      reset --hard HEAD~7
        r-h=    reset --hard HEAD@{1}
        r--h=   reset --hard HEAD@{2}
        r---h=  reset --hard HEAD@{3}
        r----h= reset --hard HEAD@{4}
        r-----h=        reset --hard HEAD@{5}
        r------h=       reset --hard HEAD@{6}
        r-------h=      reset --hard HEAD@{7}

        z=      rebase
        zi=     rebase -i
        zb=     rebase -i HEAD~1
        zbb=    rebase -i HEAD~2
        zbbb=   rebase -i HEAD~3
        zbbbb=  rebase -i HEAD~4
        zbbbbb= rebase -i HEAD~5
        zbbbbbb=        rebase -i HEAD~6
        zbbbbbbb=       rebase -i HEAD~7
        za=     rebase --abort
        zc=     rebase --continue

        fast-forward=   merge --ff-only
        ff=     merge --ff-only

        m=      merge --no-ff --allow-unrelated-histories
        mc=     merge --continue
        ma=     merge --abort
        mt=     merge-to

        br=     branch --format='\
%(if)%(HEAD)%(then)%(color:green)%(else)%(color:white)%(end)\
%(refname:short) \
%(if)%(symref)%(then)%(color:blue)-> %(color:cyan)%(symref:short) %(end)\
%(if)%(upstream:track)%(then)%(color:red ul dim)%(upstream:track,nobracket)%(color:reset) %(end)\
%(if)%(upstream)%(then)%(color:red)%(upstream:short) %(end)\
%(color:yellow dim)%(objectname:short) %(color:blue)%(authorname) \
%(color:green)%(committerdate:format:%m-%d %a %H:%M) %(color:white)%(contents:lines=1)' --sort=-committerdate

        b=      branch
        branch-all=     branch -a
        ba=     branch -a
        branch-move=    branch -m
        branch-rename=  branch -m
        bm=     branch -m
        branch-move-force=      branch -M
        branch-rename-force=    branch -M
        bmf=    branch -M
        branch-delete=  branch -d
        bd=     branch -d
        branch-delete-force=    branch -D
        bdf=    branch -D
        branch-create-into=     checkout -b
        bc=     checkout -b
        branch-create-into-force=       checkout -B
        bcf=    checkout -B
        bf=     branch -f
        branch-merge-create-into=       checkout --merge -b
        bmc=    checkout --merge -b
        branch-merge-create-into-force= checkout --merge -B
        bmcf=   checkout --merge -B

        p=      push
        psu=    push --set-upstream
        pa=     push --all
        push-force=     push -f
        pf=     push -f
        pc=     push-current-branch --set-upstream

        l=      pull
        la=     pull --all
        f=      fetch
        fa=     fetch --all
        fetch-prune=    fetch --prune
        fp=     fetch --prune
        fap=    fetch --all --prune

        hash=   log -1 --pretty=format:%H
        h=      log -1 --pretty=format:%H
        short-hash=     log -1 --pretty=format:%h
        sh=     log -1 --pretty=format:%h

        s=      status -sb -uall
        sv=     status -v

        d=      diff --ita-invisible-in-index
        diff-cached=    diff --ita-invisible-in-index --cached
        dc=     diff --ita-invisible-in-index --cached
        diff-head=      diff --ita-invisible-in-index HEAD
        dh=     diff --ita-invisible-in-index HEAD
        diff-back=      diff --ita-invisible-in-index HEAD^
        db=     diff --ita-invisible-in-index HEAD~1
        dbb=    diff --ita-invisible-in-index HEAD~2
        dbbb=   diff --ita-invisible-in-index HEAD~3
        dbbbb=  diff --ita-invisible-in-index HEAD~4
        dbbbbb= diff --ita-invisible-in-index HEAD~5
        dbbbbbb=        diff --ita-invisible-in-index HEAD~6
        dbbbbbbb=       diff --ita-invisible-in-index HEAD~7

        cp=     cherry-pick

        ignore= update-index --assume-unchanged
        i=      update-index --assume-unchanged
        unignore=       update-index --no-assume-unchanged
        ui=     update-index --no-assume-unchanged

        rv=     remote -v
        rl=     rev-list -1

        move-head=      update-ref --no-deref HEAD
        mh=     update-ref --no-deref HEAD

        detach= update-ref --no-deref HEAD HEAD
        dt=     update-ref --no-deref HEAD HEAD

        current-branch= symbolic-ref --short -q HEAD
        cb=     symbolic-ref --short -q HEAD

        vp=     rev-parse
        git-dir=        rev-parse --git-dir
        git-path=       rev-parse --git-path
        root=   rev-parse --show-toplevel

        po=     push origin
        pom=    push origin master
        poc=    !git push origin $(git cb)
        pocb=   !git push origin $(git cb)~1:$(git cb)
        pocbb=  !git push origin $(git cb)~2:$(git cb)
        pocbbb= !git push origin $(git cb)~3:$(git cb)
        pocf=   !git push -f origin $(git cb)
        ffoc=   !git merge --ff-only origin/$(git cb)
        zoc=    !git rebase origin/$(git cb)
        zoci=   !git rebase -i origin/$(git cb)
        bmc=    !git bm $(git cb)
        pub=    publish
        puba=   publish --abort
        pubc=   publish --continue
        bdo=    !echo '{'$@'}'
	addtag = "!f() { git tag -a \"$1\" -m \"$1\" && git push origin --tags; }; f"
        deletetag = "!f() { git tag -d \"$1\" && git push origin --delete \"$1\" ; }; f"
        atag = "!f() { git tag -d \"$1\" &&  git push origin --delete \"$1\"  && git tag -a \"$1\" -m \"$1\" && git push origin --tags; }; f"