Merge pull request #238 from techjacker/feature/git-fork

git-fork!
This commit is contained in:
hemanth.hm 2014-07-15 20:33:27 +05:30
commit 458c08d96b
5 changed files with 328 additions and 0 deletions

View file

@ -52,6 +52,7 @@ $ brew install git-extras
- `git alias`
- `git ignore`
- `git info`
- `git fork`
- `git release`
- `git contrib`
- `git repl`
@ -305,6 +306,36 @@ Matt Colyer (1)
total 1844
```
## git-fork
Fork the given github <repo>. Like clone but forks first.
```Shell
$ git fork https://github.com/LearnBoost/expect.js
```
or just:
```Shell
$ git fork LearnBoost/expect.js
```
Does the following:
- forks the repo (prompts for github username and pass)
- clones the repo into the current directory
- adds the original repo as a remote so can track upstream changes
- all remotes refs use git over ssh
```Shell
$ cd expect.js && git remote -v
origin git@github.com:<user>/expect.js (fetch)
origin git@github.com:<user>/expect.js (push)
original git@github.com:LearnBoost/expect.js (fetch)
original git@github.com:LearnBoost/expect.js (push)
```
## git-release
Release commit with the given &lt;tag&gt;:

34
bin/git-fork Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env sh
abort() {
echo $@
exit 1
}
# validate repo url
test -z "$1" && abort "github repo needs to be specified as an argument"
# validate user
echo "Enter your github username"
read user
[ "$user" = 'n' ] && abort "git username required"
# extract owner + project from repo url
project=${1##*/}
owner=${1%/$project}
owner=${owner##*/}
# validate
[ -z "$project" -o -z "$owner" ] && abort "github repo needs to be specified as an argument"
# create pull request
curl -X POST -u "$user" "https://api.github.com/repos/$owner/$project/forks"
[ $? = 0 ] || abort "fork failed"
# clone forked repo into current dir
git clone "git@github.com:$user/$project" "$project"
# add reference to origin fork so can merge in upstream changes
cd "$project"
git remote add upstream "git@github.com:$owner/$project"
git fetch upstream

79
man/git-fork.1 Normal file
View file

@ -0,0 +1,79 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-FORK" "1" "July 2014" "" ""
.
.SH "NAME"
\fBgit\-fork\fR \- Fork a repo on github
.
.SH "SYNOPSIS"
\fBgit\-fork\fR [<github\-repo\-url>]
.
.SH "DESCRIPTION"
Fork the given github repo\. Like clone but forks first\.
.
.IP "1." 4
forks the repo on github
.
.IP "2." 4
clones the repo into the current dir
.
.IP "3." 4
adds the original repo as a remote
.
.IP "" 0
.
.SH "EXAMPLE"
Fork expect\.js:
.
.IP "" 4
.
.nf
$ git fork https://github\.com/LearnBoost/expect\.js
.
.fi
.
.IP "" 0
.
.P
or just:
.
.IP "" 4
.
.nf
$ git fork LearnBoost/expect\.js
.
.fi
.
.IP "" 0
.
.P
Then:
.
.IP "" 4
.
.nf
$ \.\.<forks into your github profile and clones repo locally to expect\.js dir>\.\.\.
$ cd expect\.js && git remote \-v
origin git@github\.com:<user>/expect\.js (fetch)
origin git@github\.com:<user>/expect\.js (push)
original git@github\.com:LearnBoost/expect\.js (fetch)
original git@github\.com:LearnBoost/expect\.js (push)
.
.fi
.
.IP "" 0
.
.SH "AUTHOR"
Written by Andrew Griffiths <\fImail@andrewgriffithsonline\.com\fR>
.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/visionmedia/git\-extras/issues\fR>
.
.SH "SEE ALSO"
<\fIhttps://github\.com/visionmedia/git\-extras\fR>

136
man/git-fork.1.html Normal file
View file

@ -0,0 +1,136 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='content-type' value='text/html;charset=utf8'>
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
<title>git-fork(1) - Fork a repo on github</title>
<style type='text/css' media='all'>
/* style: man */
body#manpage {margin:0}
.mp {max-width:100ex;padding:0 9ex 1ex 4ex}
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
.mp h2 {margin:10px 0 0 0}
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
.mp h3 {margin:0 0 0 4ex}
.mp dt {margin:0;clear:left}
.mp dt.flush {float:left;width:8ex}
.mp dd {margin:0 0 0 9ex}
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
.mp pre {margin-bottom:20px}
.mp pre+h2,.mp pre+h3 {margin-top:22px}
.mp h2+pre,.mp h3+pre {margin-top:5px}
.mp img {display:block;margin:auto}
.mp h1.man-title {display:none}
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
.mp h2 {font-size:16px;line-height:1.25}
.mp h1 {font-size:20px;line-height:2}
.mp {text-align:justify;background:#fff}
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
.mp u {text-decoration:underline}
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
.mp b.man-ref {font-weight:normal;color:#434241}
.mp pre {padding:0 4ex}
.mp pre code {font-weight:normal;color:#434241}
.mp h2+pre,h3+pre {padding-left:0}
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
ol.man-decor {width:100%}
ol.man-decor li.tl {text-align:left}
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
ol.man-decor li.tr {text-align:right;float:right}
</style>
</head>
<!--
The following styles are deprecated and will be removed at some point:
div#man, div#man ol.man, div#man ol.head, div#man ol.man.
The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
.man-navigation should be used instead.
-->
<body id='manpage'>
<div class='mp' id='man'>
<div class='man-navigation' style='display:none'>
<a href="#NAME">NAME</a>
<a href="#SYNOPSIS">SYNOPSIS</a>
<a href="#DESCRIPTION">DESCRIPTION</a>
<a href="#EXAMPLE">EXAMPLE</a>
<a href="#AUTHOR">AUTHOR</a>
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
<a href="#SEE-ALSO">SEE ALSO</a>
</div>
<ol class='man-decor man-head man head'>
<li class='tl'>git-fork(1)</li>
<li class='tc'></li>
<li class='tr'>git-fork(1)</li>
</ol>
<h2 id="NAME">NAME</h2>
<p class="man-name">
<code>git-fork</code> - <span class="man-whatis">Fork a repo on github</span>
</p>
<h2 id="SYNOPSIS">SYNOPSIS</h2>
<p><code>git-fork</code> [&lt;github-repo-url&gt;]</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<p> Fork the given github repo. Like clone but forks first.</p>
<ol>
<li> forks the repo on github</li>
<li> clones the repo into the current dir</li>
<li> adds the original repo as a remote</li>
</ol>
<h2 id="EXAMPLE">EXAMPLE</h2>
<p> Fork expect.js:</p>
<pre><code>$ git fork https://github.com/LearnBoost/expect.js
</code></pre>
<p> or just:</p>
<pre><code>$ git fork LearnBoost/expect.js
</code></pre>
<p> Then:</p>
<pre><code>$ ..&lt;forks into your github profile and clones repo locally to expect.js dir&gt;...
$ cd expect.js &amp;&amp; git remote -v
origin git@github.com:&lt;user>/expect.js (fetch)
origin git@github.com:&lt;user>/expect.js (push)
original git@github.com:LearnBoost/expect.js (fetch)
original git@github.com:LearnBoost/expect.js (push)
</code></pre>
<h2 id="AUTHOR">AUTHOR</h2>
<p>Written by Andrew Griffiths &lt;<a href="&#x6d;&#x61;&#x69;&#108;&#116;&#111;&#x3a;&#x6d;&#x61;&#105;&#108;&#64;&#97;&#110;&#x64;&#x72;&#x65;&#119;&#103;&#x72;&#105;&#x66;&#102;&#x69;&#116;&#104;&#115;&#111;&#x6e;&#x6c;&#105;&#x6e;&#101;&#46;&#x63;&#111;&#109;" data-bare-link="true">&#109;&#97;&#x69;&#x6c;&#64;&#x61;&#x6e;&#100;&#114;&#x65;&#119;&#x67;&#x72;&#x69;&#x66;&#102;&#x69;&#116;&#x68;&#x73;&#111;&#x6e;&#x6c;&#x69;&#x6e;&#101;&#46;&#x63;&#x6f;&#109;</a>&gt;</p>
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
<p>&lt;<a href="https://github.com/visionmedia/git-extras/issues" data-bare-link="true">https://github.com/visionmedia/git-extras/issues</a>&gt;</p>
<h2 id="SEE-ALSO">SEE ALSO</h2>
<p>&lt;<a href="https://github.com/visionmedia/git-extras" data-bare-link="true">https://github.com/visionmedia/git-extras</a>&gt;</p>
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>
<li class='tc'>July 2014</li>
<li class='tr'>git-fork(1)</li>
</ol>
</div>
</body>
</html>

48
man/git-fork.md Normal file
View file

@ -0,0 +1,48 @@
git-fork(1) -- Fork a repo on github
====================================
## SYNOPSIS
`git-fork` [&lt;github-repo-url&gt;]
## DESCRIPTION
Fork the given github repo. Like clone but forks first.
1. forks the repo on github
2. clones the repo into the current dir
3. adds the original repo as a remote
## EXAMPLE
Fork expect.js:
$ git fork https://github.com/LearnBoost/expect.js
or just:
$ git fork LearnBoost/expect.js
Then:
$ ..<forks into your github profile and clones repo locally to expect.js dir>...
$ cd expect.js && git remote -v
origin git@github.com:<user>/expect.js (fetch)
origin git@github.com:<user>/expect.js (push)
original git@github.com:LearnBoost/expect.js (fetch)
original git@github.com:LearnBoost/expect.js (push)
## AUTHOR
Written by Andrew Griffiths &lt;<mail@andrewgriffithsonline.com>&gt;
## REPORTING BUGS
&lt;<https://github.com/visionmedia/git-extras/issues>&gt;
## SEE ALSO
&lt;<https://github.com/visionmedia/git-extras>&gt;