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.
Is that possible without forking the repository?
If not, is it possible at all?
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.
Is that possible without forking the repository?
If not, is it possible at all?
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!)
In June 2019, here's how I did that:
git clone https://github.com/org-a/project-x.wiki.git
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
git push -f fork master
Great. Now you have forked a repo and its wiki.
(By the way, Github should do this automatically, right?)
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!)
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.
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.
Don't skip this part. You need to understand some things.
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:
Here is an example. We will reference this image:
https://github.com/nicolargo/glances.git
[email protected]:nicolargo/glances.git
git
commands. They are the git remote server URLs.https://github.com/nicolargo/glances.wiki.git
[email protected]:nicolargo/glances.wiki.git
.git
extension, and replace it with .wiki.git
.git
commands. They are the git remote server URLs to these git repositories, for use from the command-line.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 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.
https://github.com/nicolargo/glances.git
the "main git repository".https://github.com/nicolargo/glances.wiki.git
the "accompanying wiki git repository".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".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:
Here we go:
Let's fork the glances
repository and its accompanying wiki repository.
In a web browser, log into GitHub.
Go here: https://github.com/nicolargo/glances
Click the "Fork" button at the top:
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.
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.
Click the "Wiki" link at the top of your new, forked repo. You'll see this:
Click the "Create the first page" button. In the web editor that opens, just click "Save page" in the bottom right:
I now see this, and the "Clone this wiki locally" section is now visible in the bottom-right:
GitHub has now created a nearly empty "accompanying wiki git repository" which we can work with.
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.
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"_.
Go back to your wiki page and refresh the page: https://github.com/ElectricRCAircraftGuy/glances/wiki
And voila! I now see this:
...just like the upstream wiki page, here: https://github.com/nicolargo/glances/wiki
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.
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.
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
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
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
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.
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.
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.
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
Done. The Glances wiki is copied into mine. See here: https://github.com/ElectricRCAircraftGuy/wiki_copy_demo/wiki
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.
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).
© 2022 - 2025 — McMap. All rights reserved.