diff --git a/Readme.md b/Readme.md index 51f3f2d..f097ad6 100644 --- a/Readme.md +++ b/Readme.md @@ -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:/expect.js (fetch) +origin git@github.com:/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 <tag>: diff --git a/bin/git-fork b/bin/git-fork new file mode 100755 index 0000000..5ae9a21 --- /dev/null +++ b/bin/git-fork @@ -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 \ No newline at end of file diff --git a/man/git-fork.1 b/man/git-fork.1 new file mode 100644 index 0000000..63b5d8a --- /dev/null +++ b/man/git-fork.1 @@ -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 [] +. +.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 + +$ \.\.\.\.\. + +$ cd expect\.js && git remote \-v + + origin git@github\.com:/expect\.js (fetch) + origin git@github\.com:/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> diff --git a/man/git-fork.1.html b/man/git-fork.1.html new file mode 100644 index 0000000..e6b24a7 --- /dev/null +++ b/man/git-fork.1.html @@ -0,0 +1,136 @@ + + + + + + git-fork(1) - Fork a repo on github + + + + +
+ + + +
    +
  1. git-fork(1)
  2. +
  3. +
  4. git-fork(1)
  5. +
+ +

NAME

+

+ git-fork - Fork a repo on github +

+ +

SYNOPSIS

+ +

git-fork [<github-repo-url>]

+ +

DESCRIPTION

+ +

Fork the given github repo. Like clone but forks first.

+ +
    +
  1. forks the repo on github
  2. +
  3. clones the repo into the current dir
  4. +
  5. adds the original repo as a remote
  6. +
+ + +

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 <mail@andrewgriffithsonline.com>

+ +

REPORTING BUGS

+ +

<https://github.com/visionmedia/git-extras/issues>

+ +

SEE ALSO

+ +

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

+ + +
    +
  1. +
  2. July 2014
  3. +
  4. git-fork(1)
  5. +
+ +
+ + diff --git a/man/git-fork.md b/man/git-fork.md new file mode 100644 index 0000000..bfc1cdb --- /dev/null +++ b/man/git-fork.md @@ -0,0 +1,48 @@ +git-fork(1) -- Fork a repo on github +==================================== + +## SYNOPSIS + +`git-fork` [<github-repo-url>] + +## 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: + + $ ..... + + $ cd expect.js && git remote -v + + origin git@github.com:/expect.js (fetch) + origin git@github.com:/expect.js (push) + original git@github.com:LearnBoost/expect.js (fetch) + original git@github.com:LearnBoost/expect.js (push) + + +## AUTHOR + +Written by Andrew Griffiths <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<>