Skip to content

Instantly share code, notes, and snippets.

@larrybotha
Last active October 24, 2023 21:26
Show Gist options
  • Star 47 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save larrybotha/10650410 to your computer and use it in GitHub Desktop.
Save larrybotha/10650410 to your computer and use it in GitHub Desktop.
Merge wiki updates that are on a fork of your repo.

Merge Wiki Changes From A Forked Github Repo

This is inspired (or basically copied) from How To Merge Github Wiki Changes From One Repository To Another, by Roman Ivanov, and serves to ensure that should something happen to the original article, the information remains nice and safe here.

Terminology

OREPO: original repo - the repo created or maintained by the owner

FREPO: the forked repo that presumably has updates to its wiki, not yet on the OREPO

Contributing

Should you want to contribute to the wiki of a repo you have forked, do the following:

  • fork the repo
  • clone only the wiki to your machine: $ g clone [FREPO].wiki.git
  • make changes to your local forked wiki repo
  • push your changes to GitHub

Once you are ready to let the author know you have changes, do the following:

  • open an issue on OREPO
  • provide a direct link to your wiki's git repo for ease of merging: i.e. [FREPO].wiki.git

Merging Changes

As the owner of OREPO, you have now received a message that there are updates to your wiki on someone else's FREPO.

If wiki changes are forked from latest OREPO wiki, you may do the following:

$ git clone [OREPO].wiki.git
$ cd [OREPO].wiki.git

# squashing all FREPO changes
$ git pull [FREPO].wiki.git master

$ git push origin master

If OREPO wiki is ahead of where FREPO forked from, do the following:

$ git clone [OREPO].wiki.git
$ cd [OREPO].wiki.git
$ git fetch [FREPO] master:[FREPO-branch]
$ git checkout [FREPO-branch]

#checkout to last OREPO commit
$ git reset --hard [last-OREPO-commit-hash]

# do massive squash of all FREPO changes
$ git merge --squash HEAD@{1}
$ git commit -m "Wiki update from FREPO - [description]"
$ git checkout master

# cherry-pick newly squashed commit
$ git cherry-pick [OREPO-newly-squashed-commit]
$ git push
@MSIH
Copy link

MSIH commented Sep 11, 2016

great info. i love the line "or basically copied" . i do all the time. sharing information means copying info and hopefully making it slightly better or more readable.

@sketch34
Copy link

sketch34 commented Jun 28, 2017

This doesn't work for me, I think because the forked version of the repo has no wiki. Unless I'm misunderstanding the instructions, can you clarify the steps under "Contributing"?

C:\>git clone https://github.com/sketch34/forked-repo.wiki.git
Cloning into 'forked-repo.wiki'...
fatal: remote error: access denied or repository not exported: /3/nw/72/53/30/23819746123/345824552.wiki.git

@SLrepo
Copy link

SLrepo commented Feb 1, 2018

Very helpful, thanks for sharing

@faahim
Copy link

faahim commented Feb 20, 2018

Amazing! I didn't even know wiki act as a different git! Thanks for sharing! 😄

@bitaxis
Copy link

bitaxis commented Apr 18, 2018

This gist worked for me. Thanks a lot! 👍

@jmace01
Copy link

jmace01 commented Jun 14, 2019

@sketch34, you have to create a page on your forked wiki (via the GitHub website) to create/initialize the wiki repository. Before that, it can't be accessed.

@giovp
Copy link

giovp commented Nov 5, 2019

@sketch34 same problem here, this solved it: https://stackoverflow.com/a/56480628

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