6

When forking a project on GitHub, the wiki is cloned from the original project.

Am I right to assume that I can make any changes (delete pages, edit pages) to my forked wiki without changing the upstream wiki?

I've searched Google, Stack Overflow and the GitHub documentation without finding information about this :(

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
span
  • 5,405
  • 9
  • 57
  • 115

3 Answers3

13

Forking a GitHub project does not fork its wiki repo. A blank wiki is created instead in the fork, and any changes to it cannot be merged using pull requests. A workaround to this is to clone the GitHub wiki locally then push it into a separate repository, or a separate repository's wiki, e.g.:

git clone https://github.com/user1/project.wiki.git
git remote add my-fork https://github.com/user2/project.wiki.git
git push my-fork master

To keep the wikis in sync:

git pull origin master
git push my-fork master
Oleg
  • 531
  • 3
  • 8
  • Strange, maybe they have changed the behavior since 2013? – VonC Nov 20 '15 at 15:59
  • 3
    Thanks, @Oleg, that helped! I would add that before I could `push my-fork master`, I had to (a) create the first page of a wiki under `user2`, (b) merge that new single-page wiki into the repo with `merge remotes/my-fork/master --allow-unrelated-histories`, and (c) resolve the conflict over `Home.md` and commit. – dmitrii May 03 '17 at 19:29
2

To clarify all the steps when using SSH.

git clone git@github.com:User1/Repo1.wiki.git
cd Repo1.wiki

# Now enable Wiki pages in Repo2

git remote add my-fork git@github.com:User2/Repo2.wiki.git

Pay attention to the use of : vs. / when using SSH. If something goes wrong here, you can't just repeat this command, so you need to manually change the url. To check what it is pointing to, use:

git config --local -l

# For example, this is wrong:
# remote.my-fork.url=git@github.com/User2/Repo2.wiki.git

If it is wrong, then set the correct URL with:

git config --local remote.my-fork.url git@github.com:User2/Repo2.wiki.git

Now you can continue with:

git push my-fork -f --no-tags

Where -f is shorthand for --force to overwrite all refs.

emigenix
  • 201
  • 2
  • 4
0

Update 2015/2016: you need to clone the wiki separately

And a wiki does not support pull request anyway.


2013 (Original answer): As illustrated by this project, a GitHub fork would clone:

So yes, you can fork and update the wiki without having to modify anything on the original upstream repo (the one you forked)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • If I clone a repo that has a wiki right now, the wiki is not included in the fork. See the other answer here instead. – Mr. Lance E Sloan Oct 14 '16 at 16:51
  • Enabling pull requests on GitHub wikis: http://www.growingwiththeweb.com/2016/07/enabling-pull-requests-on-github-wikis.html – Vadzim Apr 07 '18 at 11:22