陈斌彬的技术博客

Stay foolish,stay hungry

Mac Install Git-extras

Installation

Debian

$ sudo $apt_pref update
$ sudo $apt_pref install git-extras

Mac

$ brew install git-extras

img

Clone / Tarball:

$ git clone https://github.com/tj/git-extras.git
$ cd git-extras
# checkout the latest tag
$ git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
$ [sudo] make install

One-liner:

curl -sSL http://git.io/git-extras-setup | sudo bash /dev/stdin

Command

  • git extras
  • git squash
  • git summary
  • git line-summary
  • git effort
  • git authors
  • git changelog
  • git commits-since
  • git count
  • git create-branch
  • git delete-branch
  • git delete-submodule
  • git delete-tag
  • git delete-merged-branches
  • git fresh-branch
  • git guilt
  • git merge-into
  • git graft
  • git alias
  • git ignore
  • git info
  • git fork
  • git release
  • git contrib
  • git repl
  • git undo
  • git gh-pages
  • git scp
  • git setup
  • git touch
  • git obliterate
  • git feature|refactor|bug|chore
  • git local-commits
  • git archive-file
  • git missing
  • git lock
  • git locked
  • git unlock
  • git reset-file
  • git pr
  • git root
  • git delta
  • git merge-repo

git extras

The main git-extras command.

Output the current --version:

$ git extras

List available commands:

$ git extras --help

Update to the latest git-extras:

$ git extras update

git gh-pages

Sets up the gh-pages branch. (See GitHub Pages documentation.)

git summary

Outputs a repo summary:

 /Users/apple/octopress git:(source) ✗> git summary

 project  : octopress
 repo age : 6 years
 active   : 351 days
 commits  : 959
 files    : 411
 authors  :
   383  Brandon Mathis               39.9%
   114  B Mathis                     11.9%
   103  cnbin                        10.7%
    82  Frederic Hemberger           8.6%
    63  Parker Moore                 6.6%
    11  fhemberger                   1.1%
     6  B Strand                     0.6%
     6  Philip Hofstetter            0.6%
     5  Kevin W. Gisi                0.5%
     5  Rob Slifka                   0.5%
     5  dbloete                      0.5%
     4  Zhao Lü                      0.4%
     4  Alexandre Perrin             0.4%
     3  Luke Armstrong               0.3%
     3  Daniel Escoz                 0.3%

git commits-since

List commits since date (defaults to “last week”):

cnbin - 2015-6-17-1
cnbin - 2015-6-18
cnbin - 2015-6-16-17:44
cnbin - 2015-6-17:15:41
cnbin - 2015-6-17
cnbin - 2015-6-16-14:00
cnbin - 2015-6-16
cnbin - 2015-6-16-18:31
cnbin - change dream it
cnbin - 2015-6-15-12:18
cnbin - 2015-6-15-12:14
cnbin - 2015-6-15
陈斌彬 - Update 2015-06-11-typescript-jian-jie.markdown
陈斌彬 - Update 2015-05-23-dream-it.markdown
cnbin - 2015-6-13
cnbin - 2015-6-12-16:40
cnbin - 2015-6-12-12:13
cnbin - 2015-6-12
cnbin - 2015-6-11
(END)

git count

Output commit count:

$ git count

total 1844

git fork

Fork the given github . Like clone but forks first.

$ git fork https://github.com/LearnBoost/expect.js

or just:

$ git fork LearnBoost/expect.js

Does the following:

1.forks the repo (prompts for github username and pass) 2.clones the repo into the current directory 3.adds the original repo as a remote so can track upstream changes 4.all remotes refs use git over ssh

$ cd expect.js && git remote -v
origin          git@github.com:<user>/expect.js (fetch)
origin          git@github.com:<user>/expect.js (push)
upstream        git@github.com:LearnBoost/expect.js (fetch)
upstream        git@github.com:LearnBoost/expect.js (push)

git release

Release commit with the given :

$ git release 0.1.0

Does the following:

  • Executes .git/hooks/pre-release.sh (if present)
  • Commits changes (to changelog etc) with message “Release
  • Tags with the given
  • Push the branch / tags
  • Executes .git/hooks/post-release.sh (if present)

git alias

Define, search and show aliases.

Define a new alias:

$ git alias last "cat-file commit HEAD"

Search for aliases that match a pattern (one argument):

$ git alias ^la
last = cat-file commit HEAD

Show all aliases (no arguments):

$ git alias
s = status
amend = commit --amend
rank = shortlog -sn --no-merges
whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
whois = !sh -c 'git log -i -1 --pretty="format:%an <%ae>

git ignore

Too lazy to open up .gitignore? Me too!

$ git ignore build "*.o" "*.log"
... added 'build'
... added '*.o'
... added '*.log'

Without any patterns, git-ignore displays currently ignored patterns:

$ git ignore
build
*.o
*.log

git info

Show information about the repo:

➜ /Users/apple/octopress git:(source) ✗> git info

## Remote URLs:

octopress   git://github.com/imathis/octopress.git (fetch)
octopress   git://github.com/imathis/octopress.git (push)
origin  git@github.com:cnbin/cnbin.github.io.git (fetch)
origin  git@github.com:cnbin/cnbin.github.io.git (push)

## Remote Branches:

  octopress/2.5
  octopress/2.5-simplify-rakefile
  octopress/3.0-old
  octopress/HEAD -> octopress/master
  octopress/commander
  octopress/gh-pages
  octopress/guard
  octopress/jekyll-1-3
  octopress/linklog
  octopress/master
  octopress/migrator
  octopress/octopress-code-highlighter
  octopress/refactor_with_tests
  octopress/rubygemcli
  octopress/site
  octopress/site-2.1
  octopress/trace
  origin/source

## Local Branches:

* source

## Most Recent Commit:

commit 199e9a195d46362fff86ae99afe7dc16054f09f6
Author: cnbin <845040571@qq.com>

    2015-6-17-1

Type 'git log' for more commits, or 'git show <commit id>' for full commit details.

## Configuration (.git/config):

filter.lfs.clean=git lfs clean %f
filter.lfs.smudge=git lfs smudge %f
filter.lfs.required=true
push.default=simple
core.autocrlf=input
core.excludesfile=/Users/apple/.gitignore_global
alias.co=checkout
alias.br=branch
alias.ci=commit
alias.st=status
color.diff=auto
color.status=auto
color.branch=auto
color.ui=true
user.name=binbin
user.email=845040571@qq.com
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
core.autocrlf=input
remote.octopress.url=git://github.com/imathis/octopress.git
remote.octopress.fetch=+refs/heads/*:refs/remotes/octopress/*
branch.source.remote=origin
branch.source.merge=refs/heads/master
remote.origin.url=git@github.com:cnbin/cnbin.github.io.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
user.name=cnbin
user.email=845040571@qq.com

If you wish to omit(省略) the config section, you may use –no-config:

$ git info --no-config

git create-branch

Create local and remote branch name:

$ git create-branch development

git delete-branch

Delete local and remote branch name:

$ git delete-branch integration

git delete-submodule

Delete submodule name:

$ git delete-submodule lib/foo

git delete-tag

Delete local and remote tag name:

$ git delete-tag 0.0.1

git delete-merged-branches

Deletes branches that are listed in git branch --merged.

$ git delete-merged-branches
Deleted feature/themes (was c029ab3).
Deleted feature/live_preview (was a81b002).
Deleted feature/dashboard (was 923befa).
...

git fresh-branch

Create empty local branch name:

$ git fresh-branch docs

git undo

Remove the latest commit:

git undo

Remove the latest 3 commits:

git undo 3

git setup

Set up a git repository (if one doesn’t exist), add all files, and make an initial commit. dir defaults to the current working directory.

git lock

Lock a local file filename:

$ git lock config/database.yml

git locked

List local locked files:

$ git locked
config/database.yml

git unlock

Unlock a local file filename

$ git unlock config/database.yml

git reset-file

Reset one file to HEAD or certain commit

Reset one file to HEAD

$ git reset-file .htaccess

or reset one file to certain committee

$ git reset-file .htaccess dc82b19

Resource Reference