Skip to content

Instantly share code, notes, and snippets.

@johan
Forked from johan/autofork.js
Last active October 17, 2022 23:14
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save johan/1306266 to your computer and use it in GitHub Desktop.
Save johan/1306266 to your computer and use it in GitHub Desktop.
(Re)fork any gist, including your own

Want to fork your own gists? No fork button? No problem! Install this user script by clicking refork.user.js' "raw" link down below: ⇓

// ==UserScript==
// @name (Re)fork any gist, including your own
// @namespace https://github.com/johan
// @version 2.0 - updated 2015-06-21
// @description Adds a "fork" button to gists missing one at gist.github.com, so you can create multiple forks
// @match https://gist.github.com/*
// @include https://gist.github.com/*
// ==/UserScript==
if (/^\/[^\/]+\/\d+/.test(location.pathname) &&
!document.querySelector('form[action$="/fork"]')) {
var actions = document.querySelector('.gisthead .pagehead-actions')
, auth = document.querySelector('input[name="authenticity_token"]').outerHTML
, fork = document.createElement('li')
, url = location.pathname + '/fork'
;
fork.innerHTML = '<form accept-charset="UTF-8" action="'+ url + '" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓">' + auth + '</div><button class="btn btn-sm" type="submit"><span class="octicon octicon-repo-forked"></span>Fork</button></form>';
actions.appendChild(fork);
}
@ackvf
Copy link

ackvf commented Apr 18, 2022

Thank you. I've already been cloning my gists using Sourcetree and actually I've been using local repo to manipulate / clean the gist history.
Anyway, forking own repo does not seem to be supported at all: "message": "You cannot fork your own gist."

community/community#14882

@getify
Copy link

getify commented Oct 17, 2022

@RichardBronosky did you ever figure out what specifically makes a fork be indicated in the gist web interface?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment