Reputation: 4007
I want to make a build script that posts some images to imgur and updates a markdown file. I want a wiki page to be a literal .md file from the repo. Is this possible? The best I can figure out is to have a wiki page that links to a .md file.
[Link to actual wikipage](https://github.com/.../somefile.md)
This is an extra link that I don't want to follow.
Any ideas would be appreciated.
Upvotes: 3
Views: 1026
Reputation: 15079
This is easily achievable without submodules.
As already been said, github wiki is a repository itself. It can be cloned and pushed to and everything else. Any edit of a wiki-file is actually a commit.
literal .md file from the repo.
If the .md
doesn't have to be a file from the main repo (and I don't see why it has to), you can just generate it to a local wiki repository, commit and push. If indeed it has to be in the main, you can then checkout a single file.
#the link is on the wiki page
#do it outside of your main project directory
git clone https://github.com/myname/myproject.wiki.git
.md
in the wiki repoThe KISS principle in action.
#when images are posted and new file contents generated
cd /path/to/myproject.wiki
git add somefile.md
git commit -m'updated imgur files'
git push
.md
from main repo on the local machineThis is good because it takes no extra place in wiki repository. If the file is always the same and paths don't change, you can make a batch/shell script and just run it.
cd /path/to/myproject.wiki
# the "use a different working directory" magic
git --work-tree=/path/to/myproject/main/repo add somefile.md
#now it's in your index (stage).
git commit -m'updated imgur files'
git push origin
.md
from main repo on GitHubThis is the worst way, as git fetch
actually downloads the whole main repository into your wiki repository (not the actual files, but Git internal files). It takes disc space and internet bandwith. And it's an ugly solution =)
cd /path/to/myproject.wiki
git remote add mainrepo https://github.com/myname/myproject.git
git fetch mainrepo
#the "checkout one file" magic:
git checkout mainrepo/master -- somefile.md
#now it's in your working directory.
git add somefile.md
git commit -m'updated imgur files'
git push origin
Upvotes: 2
Reputation: 825
You can use a git submodule.
In your main repo you can create a submodule to the Wiki repo, then both repositories are linked. You can have the .md file in the Wiki repo, and access it from the main repo.
# in your main repo
git submodule add <link to wiki repo>
cd wiki_folder
# modify .md file
git add <file.md>
git commit
git push # it's in the remote wiki repo now
cd ..
git submodule update # the link to the wiki repo is updated
Upvotes: 2