Git扩展工具库git-extras,期待集成到git中,您值得拥有!

作者: wiflish 分类: 技术 发布时间: 2014-05-26 10:27 ė 6没有评论

https://github.com/visionmedia/git-extras

Git Extras

Little git extras.

Installation

Clone / Tarball:

<span class="nv" style="color: teal;">$ </span>make install

One-liner:

<span class="nv" style="color: teal;">$ </span><span class="o">(</span><span class="nb" style="color: #0086b3;">cd</span> /tmp <span class="o">&&</span> git clone --depth 1 https://github.com/visionmedia/git-extras.git <span class="o">&&</span> <span class="nb" style="color: #0086b3;">cd </span>git-extras <span class="o">&&</span> sudo make install<span class="o">)</span>

MacPorts

<span class="nv" style="color: teal;">$ </span>sudo port install git-extras

Brew (buggy):

<span class="nv" style="color: teal;">$ </span>brew install git-extras

Screencasts

Just getting started? Check out these screencasts:

  • introduction – covering git-ignore, git-setup, git-changelog, git-release, git-effort and more

Commands

  • git extras
  • git squash
  • git summary
  • git effort
  • git changelog
  • git commits-since
  • git count
  • git create-branch
  • git delete-branch
  • git delete-submodule
  • git delete-tag
  • git fresh-branch
  • git graft
  • git alias
  • git ignore
  • git info
  • git release
  • git contrib
  • git repl
  • git undo
  • git gh-pages
  • git setup
  • git touch
  • git obliterate
  • git feature
  • git refactor
  • git bug
  • git promote
  • git local-commits
  • git archive-file

git-extras

The main git-extras command.

Output the current --version:

<span class="nv" style="color: teal;">$ </span>git extras

List available commands:

<span class="nv" style="color: teal;">$ </span>git extras --help

Update to the latest git-extras:

<span class="nv" style="color: teal;">$ </span>git extras update

git-gh-pages

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

git-[feature|refactor|bug] [finish] <name>

Create the given feature, refactor, or bug branch name:

<span class="nv" style="color: teal;">$ </span>git feature dependencies

Afterwards, the same command will check it out:

<span class="nv" style="color: teal;">$ </span>git checkout master
<span class="nv" style="color: teal;">$ </span>git feature dependencies

When finished, we can feature finish to merge it into the current branch:

<span class="nv" style="color: teal;">$ </span>git checkout master
<span class="nv" style="color: teal;">$ </span>git feature finish dependencies

All of this works with featurebug, or refactor.

git-contrib <author>

Output author‘s contributions to a project:

<span class="nv" style="color: teal;">$ </span>git contrib visionmedia
visionmedia <span class="o">(</span>18<span class="o">)</span>:
  Export STATUS_CODES
  Replaced several Array.prototype.slice.call<span class="o">()</span> calls with Array.prototype.unshift.call<span class="o">()</span>
  Moved <span class="nb" style="color: #0086b3;">help </span>msg to node-repl
  Added multiple arg support <span class="k">for </span>sys.puts<span class="o">()</span>, print<span class="o">()</span>, etc.
  Fix stack output on socket error
  ...

git-summary

Outputs a repo summary:

<span class="nv" style="color: teal;">$ </span>git summary

project  : git-extras
repo age : 10 months ago
commits  : 163
active   : 60 days
files    : 93
authors  :
   97   Tj Holowaychuk          59.5%
   37   Jonhnny Weslley         22.7%
    8   Kenneth Reitz           4.9%
    5   Aggelos Orfanakos       3.1%
    3   Jonathan <span class="s2" style="color: #dd1144;">"Duke"</span> Leto    1.8%
    2   Gert Van Gool           1.2%
    2   Domenico Rotiroti       1.2%
    2   Devin Withers           1.2%
    2   TJ Holowaychuk          1.2%
    1   Nick Campbell           0.6%
    1   Alex McHale             0.6%
    1   Jason Young             0.6%
    1   Jens K. Mueller         0.6%
    1   Guillermo Rauch         0.6%

This command can also take a commitish, and will print a summary for commits in the commmitish range:

<span class="nv" style="color: teal;">$ </span>git summary v42..

git-effort [file ....]

Displays “effort” statistics, currently just the number of commits per file, showing highlighting where the most activity is. The “active days” column is the total number of days which contributed modifications to this file.

<code>node (master): git effort --above 15 {src,lib}/*
</code>

git effort

If you wish to ignore files with commits <= a value you may use --above:

<code>$ git effort --above 5
</code>

By default git ls-files is used, however you may pass one or more files to git-effort(1), for example:

<code>$ git effort bin/* lib/*
</code>

git-repl

GIT read-eval-print-loop:

<span class="nv" style="color: teal;">$ </span>git repl

git> ls-files
History.md
Makefile
Readme.md
bin/git-changelog
bin/git-count
bin/git-delete-branch
bin/git-delete-tag
bin/git-ignore
bin/git-release

git> quit

git-commits-since [date]

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

<span class="nv" style="color: teal;">$ </span>git commits-since
... changes since last week
TJ Holowaychuk - Fixed readme
TJ Holowaychuk - Added git-repl
TJ Holowaychuk - Added git-delete-tag
TJ Holowaychuk - Added git-delete-branch

<span class="nv" style="color: teal;">$ </span>git commits-since yesterday
... changes since yesterday
TJ Holowaychuk - Fixed readme

git-count

Output commit count:

<span class="nv" style="color: teal;">$ </span>git count

total 1844

Output detailed commit count:

<span class="nv" style="color: teal;">$ </span>git count --all

visionmedia <span class="o">(</span>1285<span class="o">)</span>
Tj Holowaychuk <span class="o">(</span>430<span class="o">)</span>
Aaron Heckmann <span class="o">(</span>48<span class="o">)</span>
csausdev <span class="o">(</span>34<span class="o">)</span>
ciaranj <span class="o">(</span>26<span class="o">)</span>
Guillermo Rauch <span class="o">(</span>6<span class="o">)</span>
Brian McKinney <span class="o">(</span>2<span class="o">)</span>
Nick Poulden <span class="o">(</span>2<span class="o">)</span>
Benny Wong <span class="o">(</span>2<span class="o">)</span>
Justin Lilly <span class="o">(</span>1<span class="o">)</span>
isaacs <span class="o">(</span>1<span class="o">)</span>
Adam Sanderson <span class="o">(</span>1<span class="o">)</span>
Viktor Kelemen <span class="o">(</span>1<span class="o">)</span>
Gregory Ritter <span class="o">(</span>1<span class="o">)</span>
Greg Ritter <span class="o">(</span>1<span class="o">)</span>
ewoudj <span class="o">(</span>1<span class="o">)</span>
James Herdman <span class="o">(</span>1<span class="o">)</span>
Matt Colyer <span class="o">(</span>1<span class="o">)</span>

total 1844

git-release

Release commit with the given <tag>:

<span class="nv" style="color: teal;">$ </span>git release 0.1.0

Does the following:

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

git-alias

Define, search and show aliases.

Define a new alias:

<span class="nv" style="color: teal;">$ </span>git <span class="nb" style="color: #0086b3;">alias </span>last <span class="s2" style="color: #dd1144;">"cat-file commit HEAD"</span>

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

<span class="nv" style="color: teal;">$ </span>git <span class="nb" style="color: #0086b3;">alias</span> ^la
<span class="nv" style="color: teal;">last</span> <span class="o">=</span> cat-file commit HEAD

Show all aliases (no arguments):

<span class="nv" style="color: teal;">$ </span>git <span class="nb" style="color: #0086b3;">alias</span>
<span class="nv" style="color: teal;">s</span> <span class="o">=</span> status
<span class="nv" style="color: teal;">amend</span> <span class="o">=</span> commit --amend
<span class="nv" style="color: teal;">rank</span> <span class="o">=</span> shortlog -sn --no-merges
<span class="nv" style="color: teal;">whatis</span> <span class="o">=</span> show -s --pretty<span class="o">=</span><span class="s1" style="color: #dd1144;">'tformat:%h (%s, %ad)'</span> --date<span class="o">=</span>short
<span class="nv" style="color: teal;">whois</span> <span class="o">=</span> !sh -c <span class="err" style="color: #a61717;">'</span>git log -i -1 --pretty<span class="o">=</span><span class="err" style="color: #a61717;">"</span>format:%an <%ae>

git-ignore [pattern ...]

Too lazy to open up .gitignore? Me too!

<span class="nv" style="color: teal;">$ </span>git ignore build <span class="s2" style="color: #dd1144;">"*.o"</span> <span class="s2" style="color: #dd1144;">"*.log"</span>
... added <span class="s1" style="color: #dd1144;">'build'</span>
... added <span class="s1" style="color: #dd1144;">'*.o'</span>
... added <span class="s1" style="color: #dd1144;">'*.log'</span>

Add patterns from an existing template:

<span class="nv" style="color: teal;">$ </span>git ignore -t rails

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

<span class="nv" style="color: teal;">$ </span>git ignore
build
*.o
*.log

git-info

Show information about the repo:

<span class="nv" style="color: teal;">$ </span>git info

    <span class="c" style="font-style: italic; color: #999988;">## Remote URLs:</span>

    origin              git@github.com:sampleAuthor/git-extras.git <span class="o">(</span>fetch<span class="o">)</span>
    origin              git@github.com:sampleAuthor/git-extras.git <span class="o">(</span>push<span class="o">)</span>

    <span class="c" style="font-style: italic; color: #999988;">## Remote Branches:</span>

    origin/HEAD -> origin/master
    origin/myBranch

    <span class="c" style="font-style: italic; color: #999988;">## Local Branches:</span>

    myBranch
    * master

    <span class="c" style="font-style: italic; color: #999988;">## Most Recent Commit:</span>

    commit e3952df2c172c6f3eb533d8d0b1a6c77250769a7
    Author: Sample Author <sampleAuthor@gmail.com>

    Added git-info command.

    Type <span class="s1" style="color: #dd1144;">'git log'</span> <span class="k">for </span>more commits, or <span class="s1" style="color: #dd1144;">'git show <commit id>'</span> <span class="k">for </span>full commit details.

    <span class="c" style="font-style: italic; color: #999988;">## Configuration (.git/config):</span>

    color.diff<span class="o">=</span>auto
    color.status<span class="o">=</span>auto
    color.branch<span class="o">=</span>auto
    user.name<span class="o">=</span>Sample Author
    user.email<span class="o">=</span>sampleAuthor@gmail.com
    core.repositoryformatversion<span class="o">=</span>0
    core.filemode<span class="o">=</span><span class="nb" style="color: #0086b3;">true</span>
core.bare<span class="o">=</span><span class="nb" style="color: #0086b3;">false</span>
core.logallrefupdates<span class="o">=</span><span class="nb" style="color: #0086b3;">true</span>
core.ignorecase<span class="o">=</span><span class="nb" style="color: #0086b3;">true</span>
remote.origin.fetch<span class="o">=</span>+refs/heads/*:refs/remotes/origin/*
    remote.origin.url<span class="o">=</span>git@github.com:mub/git-extras.git
    branch.master.remote<span class="o">=</span>origin
    branch.master.merge<span class="o">=</span>refs/heads/master

If you wish to omit the config section, you may use --no-config:

<span class="nv" style="color: teal;">$ </span>git info --no-config

git-create-branch <name>

Create local and remote branch name:

<span class="nv" style="color: teal;">$ </span>git create-branch development

git-delete-branch <name>

Delete local and remote branch name:

<span class="nv" style="color: teal;">$ </span>git delete-branch integration

git-delete-submodule <name>

Delete submodule name:

<span class="nv" style="color: teal;">$ </span>git delete-submodule lib/foo

git-delete-tag <name>

Delete local and remote tag name:

<span class="nv" style="color: teal;">$ </span>git delete-tag 0.0.1

git-fresh-branch <name>

Create empty local branch name:

<span class="nv" style="color: teal;">$ </span>git fresh-branch docs

git-graft <src-branch> [dest-branch]

Merge commits from src-branch into dest-branch. (dest-branch defaults to master.)

<span class="nv" style="color: teal;">$ </span>git graft new_feature dev
<span class="nv" style="color: teal;">$ </span>git graft new_feature

git-squash <src-branch> [msg]

Merge commits from src-branch into the current branch as a single commit. When [msg] is given git-commit(1) will be invoked with that message. This is useful when small individual commits within a topic branch are irrelevant and you want to consider the topic as a single change.

<span class="nv" style="color: teal;">$ </span>git squash fixed-cursor-styling
<span class="nv" style="color: teal;">$ </span>git squash fixed-cursor-styling <span class="s2" style="color: #dd1144;">"Fixed cursor styling"</span>

git-changelog

Populate a file whose name matches change|history -i_ with commits since the previous tag. (If there are no tags, populates commits since the project began.)

Opens the changelog in $EDITOR when set.

<span class="nv" style="color: teal;">$ </span>git changelog --tag 1.5.2 <span class="o">&&</span> cat History.md

1.5.2 / 2010-08-05
<span class="o">==================</span>

* Docs <span class="k">for </span>git-ignore. Closes <span class="c" style="font-style: italic; color: #999988;">#3</span>
* Merge branch <span class="s1" style="color: #dd1144;">'ignore'</span>
* Added git-ignore
* Fixed <tag> in docs
* Install docs
* Merge branch <span class="s1" style="color: #dd1144;">'release'</span>
* Added git-release
* Passing args to git shortlog
* Added --all support to git-count
* Initial commit

List commits:

<span class="nv" style="color: teal;">$ </span>git changelog --list

* Docs <span class="k">for </span>git-ignore. Closes <span class="c" style="font-style: italic; color: #999988;">#3</span>
* Merge branch <span class="s1" style="color: #dd1144;">'ignore'</span>
* Added git-ignore
* Fixed <tag> in docs
* Install docs
* Merge branch <span class="s1" style="color: #dd1144;">'release'</span>
* Added git-release
* Passing args to git shortlog
* Added --all support to git-count
* Initial commit

git-undo

Remove the latest commit:

git undo

Remove the latest 3 commits:

git undo 3

git-setup [dir]

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-touch [filename]

Call touch on the given file, and add it to the current index. One-step creation of new files.

git-obliterate [filename]

Completely remove a file from the repository, including past commits and tags.

git obliterate secrets.json

git-local-commits

List all commits on the local branch that have not yet been sent to origin. Any additional arguments will be passed directly to git log.

git-archive-file

Creates an zip archive of the current git repository. The name of the archive will depend on the current HEAD of your git respository.

 

 

本文出自 Wiflish's Blog,转载时请注明出处及相应链接。

本文永久链接: http://wiflish.fyard.com/archives/197

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Ɣ回顶部