On GitHub, can I fork just a wiki?
Asked Answered
M

6

45

If I fork repository joe/foo, and it has a Wiki, I won't get the wiki. Right now I'm just interested in forking the wiki to add pages to it.

  1. Is that possible without forking the repository?

  2. If not, is it possible at all?

Malleolus answered 25/8, 2011 at 22:24 Comment(1)
Related: How can I make a pull request for a wiki page on GitHub?Warman
V
17

You can't fork it directly on GitHub, but you can get Git access to it by going into the Git access tab of the wiki and you should be able to fork it on your local machine and edit it as much as you want (and even get updates to it!)

Viand answered 25/8, 2011 at 22:28 Comment(5)
But I guess there's no way to have it show up in that fork graph thingy?Malleolus
I don't think so, wiki's are separate from the actual repo.Viand
Well... there is #15081348Emelia
If I can't fork it, I also can't send pull request on wiki pages right?Evildoer
@MattS., In't there an easier way to do this?Ellord
Z
28

In June 2019, here's how I did that:

  1. Fork a repo. The wiki is not forked automatically. So your fork will have empty wiki.
  2. Create a wiki in the forked repo. Just create an empty Home page or whatever.
  3. Clone the git repo of original wiki: git clone https://github.com/org-a/project-x.wiki.git
  4. Assuming your forked repo now sits in https://github.com/org-b/project-x, add the new remote to the wiki repo: git remote add fork https://github.com/org-b/project-x.wiki.git
  5. Do the force push to overwrite your wiki with the original git push -f fork master

Great. Now you have forked a repo and its wiki.

(By the way, Github should do this automatically, right?)

Zuzana answered 6/6, 2019 at 15:20 Comment(5)
So as a result, you have two separate repo: one for code and one for wiki, but you can't create a pull request for the wiki repo, can you?Luanaluanda
No, I just did this only to discover there is no way to contribute my Wiki changes. WTF, Github?Ednaedny
Well, does not work any more, because authentication does not work. you have to access the repo via SSH in order to be able to write to it from console. But access to WIKI.git only goes through HTTPS. Am I right or does anybody know a solution?Astound
It works using HTTPS and personal access tokens as described here docs.github.com/en/authentication/…Astound
Your answer is fine. I've upvoted it. But, for beginners who need a lot more detail, they can check out my answer here. Note also that I've inverted it. Instead of cloning the upstream repo but pushing it to your new wiki repo like you've done, I clone the new wiki repo and fetch the upstream wiki repo, hard reset onto it, then force push. This way they end up with their own "accompanying wiki git repository" stored locally which they can use to edit their own wiki.Warman
V
17

You can't fork it directly on GitHub, but you can get Git access to it by going into the Git access tab of the wiki and you should be able to fork it on your local machine and edit it as much as you want (and even get updates to it!)

Viand answered 25/8, 2011 at 22:28 Comment(5)
But I guess there's no way to have it show up in that fork graph thingy?Malleolus
I don't think so, wiki's are separate from the actual repo.Viand
Well... there is #15081348Emelia
If I can't fork it, I also can't send pull request on wiki pages right?Evildoer
@MattS., In't there an easier way to do this?Ellord
T
5

You are able to just clone a Wiki from a repo now. You can find a tab called Git Access under Wiki tab of a repo.

But you still can not fork a wiki without forking its project repo.

Thumbstall answered 26/2, 2012 at 11:29 Comment(0)
W
3

On GitHub, can I fork just a wiki?

Yes, but it requires using git from the command-line. If on Windows, you will need the Git Bash terminal which comes with Git for Windows, to run git commands at the command-line. On Mac or Linux, use your regular terminal.

Below, I present three options to fork a wiki.

The following concepts apply to any of the major git-based hosting platforms, including GitHub and Atlassian BitBucket. My tests and screenshots are from GitHub. I imagine that the same concepts would also apply to GitLab and others, but I have not tested it. This practice of making the "wiki" into a separate git repo from your main git repo is pretty common among the big code hosting platforms.

Background knowledge

Don't skip this part. You need to understand some things.

Git vs GitHub; branches and repos:

Just like every git branch is actually made up of up to 3 branches, which confuses the heck out of everybody (see my comment here, and the answer above it), every GitHub repository is actually made up of up to 2 git repositories, which also confuses the heck out of everybody. Remember: GitHub is not git! Git is a command-line version control tool. GitHub simply uses git. GitHub can do whatever the heck they want. They could store 1000 git repositories for every GitHub repository if they wanted.

So, the two underlying git repositories in a single GitHub repository are:

  1. The main git repository you generally push and pull to, and fork.
  2. The secondary git repository used to store the wiki pages only, so long as you have created at least one page on the wiki.

Example

Here is an example. We will reference this image: enter image description here

  1. The main GitHub repo: https://github.com/nicolargo/glances
    1. Click the green "Code" button shown in the image above to view the git URLs to it.
    2. Git URLs:
      1. HTTPS: https://github.com/nicolargo/glances.git
      2. SSH: [email protected]:nicolargo/glances.git
      3. These Git URLS are not intended to be accessed in your browser! They are not webpages. They are intended to be used only at the command-line with git commands. They are the git remote server URLs.
  2. The main GitHub repo's corresponding wiki repo, which exists since this GitHub repo has at least one wiki page: go to https://github.com/nicolargo/glances --> click the "Wiki" tab at the top, as shown in the image above.
    1. Direct link to the wiki: https://github.com/nicolargo/glances/wiki
    2. In the bottom-right of the wiki page, see the "Clone this wiki locally" section to view the git HTTPS URL to it:
      1. enter image description here
    3. Git URLs:
      1. HTTPS: https://github.com/nicolargo/glances.wiki.git
      2. SSH: [email protected]:nicolargo/glances.wiki.git
        1. Important!
          1. This URL is not shown in the image just above, but it does work and exist. All you do is take your main git repo URL, remove the .git extension, and replace it with .wiki.git.
          2. Prefer the HTTPS git URLs for read-only access to someone else's git repos, and prefer the SSH URLs for read/write access to your own git repos.
      3. Again, these Git URLs are not webpages! They are for use only at the command-line with git commands. They are the git remote server URLs to these git repositories, for use from the command-line.

Git limitations

None. A git repository is a git repository is a git repository. You have two git repositories above. Their HTTPS URLs are https://github.com/nicolargo/glances.git and https://github.com/nicolargo/glances.wiki.git. You can do anything you want to it via git commands at the command-line. Again, in Windows, use the Git Bash Linux-emulation terminal, and on Linux or Mac, use your regular terminal.

GitHub limitations

GitHub only supports forking the main repository (at git remote server HTTPS URL https://github.com/nicolargo/glances.git, in this case). It does not support forking the wiki repository. It also only supports Issues, branch protections, pull requests, etc., on the main repository. It does not support them on the wiki repository. For the wiki repository, just editing a wiki page in the GitHub web editor online creates a commit and pushes automatically. There is no pull request, no branch protection, no Issues, etc.

If you want all of those features, you need to put your wiki pages into the main repository as markdown pages within it. That's fine, but then you have a more cumbersome process for community members to update the wiki pages, because now your "wiki" pages will be in the main, highly-regulated git repository, rather than in the unregulated wiki git repository. GitHub intentionally makes the wiki repository easy to modify, but also unprotected.

Let's define some terms

  1. Let's call https://github.com/nicolargo/glances.git the "main git repository".
  2. Let's call https://github.com/nicolargo/glances.wiki.git the "accompanying wiki git repository".
  3. If you move the contents of https://github.com/nicolargo/glances.wiki.git into https://github.com/nicolargo/glances.git, which you can do via git at the command-line by the way, let's call that concept "wiki pages in your main git repository", or "markdown pages in your main git repository".
  4. If you delete https://github.com/nicolargo/glances.wiki.git and move it into its own stand-alone main GitHub repository, then you will now have the ability to fork it, create Issues, have pull requests, etc. Let's call that concept a "main git repository which is used as a wiki".

In my answer below, I will cover forking 1, 2, and 4 above in 3 separate ways:

  1. [most common] How to fork the "main git repository" and its "accompanying wiki git repository".
  2. How to copy an "accompanying wiki git repository" into a new "main git repository" to create a "main git repository which is used as a wiki".
  3. How to fork an "accompanying wiki git repository" into the "accompanying wiki git repository" of any other "main git repository".

Here we go:

Option 1 [most common]: fork the "main git repository" and its "accompanying wiki git repository"

Let's fork the glances repository and its accompanying wiki repository.

  1. In a web browser, log into GitHub.

  2. Go here: https://github.com/nicolargo/glances

  3. Click the "Fork" button at the top:

    enter image description here

    On the page that opens, click "Create fork".

    My username is ElectricRCAircraftGuy.

    I now have this fork of glances, with my username in the webpage URL: https://github.com/ElectricRCAircraftGuy/glances

    If I click the green "Code" button --> "SSH" tab, I can see my git SSH URL: [email protected]:ElectricRCAircraftGuy/glances.git. My HTTPS URL is https://github.com/ElectricRCAircraftGuy/glances.git.

    In my terminal on my computer, I can clone the repo:

    # What I will run to clone my own repo with read/write permissions
    git clone [email protected]:ElectricRCAircraftGuy/glances.git
    
    # What others can run to clone my repo with read-only permissions
    git clone https://github.com/ElectricRCAircraftGuy/glances.git
    

    [x] Forking the "main git repository" is now done. But, forking the "accompanying wiki git repository" is not done yet.

  4. Try to clone the "accompanying wiki git repository" to prove it does not exist yet.

    I know from experience that GitHub does not fork the wiki repository when you fork the main repository. I also know that the "accompanying wiki git repository's" git URLs will be as follows. Simply remove .git from your "main git repository's" git URLs, and add .wiki.git instead:

    "accompanying wiki git repository" git URLs:

    # What I will run to clone my own accompanying wiki git repo with 
    # read/write permissions
    git clone [email protected]:ElectricRCAircraftGuy/glances.wiki.git
    
    # What others can run to clone my accompanying wiki git repo with 
    # read-only permissions
    git clone https://github.com/ElectricRCAircraftGuy/glances.wiki.git
    

    So, if I run git clone [email protected]:ElectricRCAircraftGuy/glances.wiki.git, I'll get this error, as expected, since my forked repo does not have an "accompanying wiki git repository" yet:

    $ git clone [email protected]:ElectricRCAircraftGuy/glances.wiki.git
    Cloning into 'glances.wiki'...
    ERROR: Repository not found.
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
  5. Click the "Wiki" link at the top of your new, forked repo. You'll see this:

    enter image description here

    Click the "Create the first page" button. In the web editor that opens, just click "Save page" in the bottom right:

    enter image description here

    I now see this, and the "Clone this wiki locally" section is now visible in the bottom-right:

    enter image description here

    GitHub has now created a nearly empty "accompanying wiki git repository" which we can work with.

  6. Clone your empty "accompanying wiki git repository":

    # What I will run to clone my own accompanying wiki git repo with 
    # read/write permissions
    git clone [email protected]:ElectricRCAircraftGuy/glances.wiki.git
    
    # What others can run to clone my accompanying wiki git repo with 
    # read-only permissions
    git clone https://github.com/ElectricRCAircraftGuy/glances.wiki.git
    

    This works fine now. I run:

    git clone [email protected]:ElectricRCAircraftGuy/glances.wiki.git
    

    This creates a new glances.wiki folder on my computer, with the .git folder in it, of course, plus a single Home.md markdown file in it, which contains the Wiki home page you see online at https://github.com/ElectricRCAircraftGuy/glances/wiki.

  7. Command-line work: fork the original glances "accompanying wiki git repository" into your new, empty "accompanying wiki git repository"

    # cd into your new, empty accompanying wiki git repo
    cd glances.wiki
    
    # view your git remotes; the "origin" one is the one you just cloned
    # from your own new _"accompanying wiki git repository"_
    git remote -v
    
    # Add the original glances repo as a remote repo, and call it "upstream"; 
    # use the HTTP git URL for read-only access
    git remote add upstream https://github.com/nicolargo/glances.wiki.git
    
    # prove you've added it
    git remote -v
    
    # fetch the upstream _"accompanying wiki git repository"_ you just added
    git fetch upstream
    
    # view your remote git branches you just fetched, and make note of the 
    # "upstream" one. I see the following:
    #       origin/HEAD -> origin/master
    #       origin/master
    #       upstream/master      <==== the upstream branch we need later
    git branch -r
    
    # Ensure `git status` is clean, and that you don't have any local, 
    # uncommitted changes to your _"accompanying wiki git repository"_. 
    # It should say: "nothing to commit, working tree clean".
    git status
    
    # back up your branch in case you royally screw this up
    git branch my_backup_branch
    
    # hard reset your branch to the upstream you just fetched, which is called
    # "upstream/master" in my case, as shown above
    git reset --hard upstream/master
    
    # List files to see you now have all pages from the upstream wiki
    ls
    
    # Force push it to yoru own _"accompanying wiki git repository"_
    git push -f  # see WARNING WARNING WARNING below; never do this again on
                 # your _"accompanying wiki git repository"_.
    
  8. Go back to your wiki page and refresh the page: https://github.com/ElectricRCAircraftGuy/glances/wiki

    And voila! I now see this:

    enter image description here

    ...just like the upstream wiki page, here: https://github.com/nicolargo/glances/wiki

  9. Done. I hope you thoroughly understand now that a GitHub "accompanying wiki git repository" is just another regular git repo like any other git repo! Just use the command-line.

    Note: I use the command-line to write and edit my wiki pages too. Then I push them. I hardly use the online wiki editor on GitHub.

    WARNING WARNING WARNING: never ever force push git push -f again, or else you permanently wipe other peoples' changes that they make via the web interface, and since people editing the wiki via the web interface don't have the "accompanying wiki git repository" cloned locally, they can't recover their changes, ever. You will erase their work forever.

    So, if you edit the wiki via the command line, and git push fails, NEVER use -f. Instead, pull the latest changes, merge them with yours, and git push again cleanly.

Option 2: copy an "accompanying wiki git repository" into a new "main git repository" to create a "main git repository which is used as a wiki"

I'm not going to include so many details from this point forward. The above instructions should be enough to get you going as a beginner.

This option is most useful if you want to have a professional wiki page with branch protections, Issues, pull requests, etc. This is what I use at work to create wikis for my team. In this case, the "wiki" is just a regular git repo which we use as a wiki by storing a ton of linked markdown files in it.

  1. Go to GitHub in a browser and make a new repo. I'll call mine glances_wiki. It's here: https://github.com/ElectricRCAircraftGuy/glances_wiki

  2. Now do everything locally from the terminal:

    # Clone it locally, using the SSH git URL
    git clone [email protected]:ElectricRCAircraftGuy/glances_wiki.git
    
    # cd into it
    cd glances_wiki
    
    # add the original _"accompanying wiki git repository"_ of the glances repo
    # as an upstream to your new _"main git repository"_
    git remote add upstream https://github.com/nicolargo/glances.wiki.git
    
    # fetch the upstream _"accompanying wiki git repository"_ you just added
    git fetch upstream
    
    # hard reset onto it; WARNING WARNING: hard reset will wipe local changes
    git reset --hard upstream/master
    
    # force push it to your own _"main git repository"_; WARNING WARNING: 
    # this permanently wipes changes in your remote "origin" on github
    # for this repo
    git push -f
    
  3. Done. Check it out: https://github.com/ElectricRCAircraftGuy/glances_wiki

    The "Home.md" page is now the main page of this "main git repository which is used as a wiki". Rename that file to "README.md" if you want it to show up automatically on the website when you view the repo in a browser on GitHub.

    Ironically enough, my "main git repository which is used as a wiki" also now has a wiki page, so technically you can have a wiki of your wiki. Here is that page. It's empty: https://github.com/ElectricRCAircraftGuy/glances_wiki/wiki

Option 3: fork an "accompanying wiki git repository" into the "accompanying wiki git repository" of any other "main git repository"

This option is most useful if you just want to copy the "accompanying wiki git repository" of one repo into the "accompanying wiki git repository" of another repo, while keeping the their corresponding "main git repositories" separate and distinct.

  1. For this demo, I'm creating a nearly-empty repo called wiki_copy_demo, here: https://github.com/ElectricRCAircraftGuy/wiki_copy_demo This is basically just Option 1 again, but into a different GitHub repo instead of the forked one.

  2. Add at least one page to your destination Wiki--same as before in Option 1. Here's mine: https://github.com/ElectricRCAircraftGuy/wiki_copy_demo/wiki.

  3. Now, let's copy the glances upstream "accompanying wiki git repository" into the "accompanying wiki git repository" of this new wiki_copy_demo repo:

    # Clone your new _"accompanying wiki git repository"_ locally, using the 
    # SSH git URL
    git clone [email protected]:ElectricRCAircraftGuy/wiki_copy_demo.wiki.git
    # cd into it
    cd wiki_copy_demo.wiki
    
    # add the original _"accompanying wiki git repository"_ of the glances repo
    # as an upstream to your new _"accompanying wiki git repository"_
    git remote add upstream https://github.com/nicolargo/glances.wiki.git
    
    # fetch the upstream _"accompanying wiki git repository"_ you just added
    git fetch upstream
    
    # hard reset onto it; WARNING WARNING: hard reset will wipe local changes
    git reset --hard upstream/master
    
    # force push it to your own _"accompanying wiki git repository"_; 
    # WARNING WARNING: this permanently wipes changes in your remote 
    # "origin" on github for this repo
    git push -f
    
  4. Done. The Glances wiki is copied into mine. See here: https://github.com/ElectricRCAircraftGuy/wiki_copy_demo/wiki

See also

  1. My answer to How can I make a pull request for a wiki page on GitHub?
Warman answered 14/10, 2023 at 19:37 Comment(0)
B
2

If you're making your own wiki that others would be interested in forking, you could do something like we did for the RailsConf 2012 wiki.

We made a local clone of the wiki and then did git push --force to the "code" repository. It gets a little out of sync, but that's easy to rectify.

Boesch answered 21/6, 2012 at 17:38 Comment(0)
K
-3

As of 30 March 2016, you can just create a new "Home" Wiki page and the wiki pages for the forked repository will show up in your fork once the new Home page is created (provided that you have forked the parent repository).

Kiker answered 30/3, 2016 at 23:0 Comment(2)
Note that it will just say a 'Home' page already exists when you try creating one and pull in the wiki repository from the original project. It kinda looks like a bug to be honest. It just 'notices' there already is a wiki when you try to create a page.Bareback
At the time of this comment, this answer doesn't work. The About GitHub Wikis page uses the Netflix/Hystrix wiki as an example. I can access that repo and wiki. I forked the repo to my account. In my fork the wiki was empty, as expected. As this answer suggests, I created a "Home" wiki page. GitHub created it without comment/error. Afterwards, the wiki in my fork contained only the new Home page and no others. This answer is wrong.Tackling

© 2022 - 2025 — McMap. All rights reserved.