Skip to content

Commit 4c71176

Browse files
committed
docs: add guidelines for force pushing to GitHub Wiki and troubleshooting subtree sync issues
1 parent d7dd920 commit 4c71176

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

docs/Wiki-Management.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,41 @@ git subtree push --prefix=docs wiki master
123123
- Pushes them to the GitHub wiki repository
124124
- Updates the online wiki at `https://github.com/DevKor-github/OnTime-front/wiki`
125125

126+
### Force push to GitHub Wiki (use with extreme caution)
127+
128+
Sometimes the wiki remote can get out of sync (e.g., someone edited pages directly on GitHub and you want to **overwrite** the wiki with your local `docs/` state). In that case, you _can_ force push — but note:
129+
130+
- **This rewrites the wiki repo history** and can discard other people's edits.
131+
- Only do this if the team agrees and you’re sure your local `docs/` is the desired source of truth.
132+
- Consider pulling first (`git subtree pull --prefix=docs wiki master --squash`) to avoid needing force.
133+
134+
`git subtree push` doesn’t accept `--force`, so you force-push by splitting and pushing the split commit:
135+
136+
```bash
137+
# 0) Make sure your docs changes are committed
138+
git status
139+
140+
# 1) Create a split commit containing only docs/ history
141+
git subtree split --prefix=docs -b docs/wiki-split
142+
143+
# 2) Force push that split to the wiki remote
144+
git push wiki docs/wiki-split:master --force
145+
```
146+
147+
If you don’t want to keep the temporary branch around:
148+
149+
```bash
150+
# Create the split commit SHA and force push it directly
151+
SPLIT_SHA=$(git subtree split --prefix=docs HEAD)
152+
git push wiki "$SPLIT_SHA":master --force
153+
```
154+
155+
Afterwards, it’s safe to delete the temp branch:
156+
157+
```bash
158+
git branch -D docs/wiki-split
159+
```
160+
126161
### Pull Changes from GitHub Wiki
127162

128163
If someone edits the wiki directly on GitHub:
@@ -138,6 +173,52 @@ git subtree pull --prefix=docs wiki master --squash
138173
- You want to sync external wiki changes to your local repository
139174
- Before starting major documentation work (to avoid conflicts)
140175

176+
### Troubleshooting subtree sync
177+
178+
**Issue: `fatal: working tree has modifications. Cannot add.`**
179+
180+
`git subtree pull` requires a clean working tree.
181+
182+
```bash
183+
git status
184+
# then either commit or stash
185+
git add docs/
186+
git commit -m "docs: WIP before subtree pull"
187+
# or
188+
git stash -u
189+
```
190+
191+
**Issue: `fatal: refusing to merge unrelated histories`**
192+
193+
This happens when your local `docs/` history and the GitHub wiki repository don’t share a common subtree “join” history (often because `docs/` wasn’t originally introduced via `git subtree add`, or the wiki was rewritten independently).
194+
195+
Pick one of these paths:
196+
197+
1. **Overwrite wiki with local `docs/`** (recommended if `docs/` is the source of truth):
198+
199+
```bash
200+
git status
201+
git subtree split --prefix=docs -b docs/wiki-split
202+
git push wiki docs/wiki-split:master --force-with-lease
203+
git branch -D docs/wiki-split
204+
```
205+
206+
2. **Import wiki into this repo (one-time) and then merge your local docs** (recommended if the wiki is the source of truth):
207+
208+
```bash
209+
# Backup current docs
210+
git mv docs docs_local
211+
git commit -m "chore(docs): backup local docs before importing wiki"
212+
213+
# Bring wiki content into docs/ (establishes subtree join history)
214+
git subtree add --prefix=docs wiki master --squash
215+
216+
# Now manually reconcile docs_local/ -> docs/ as needed, then:
217+
rm -rf docs_local
218+
git add -A
219+
git commit -m "docs: reconcile local docs with wiki import"
220+
```
221+
141222
## 🔧 Advanced Workflows
142223

143224
### Working on Documentation-Heavy Features

0 commit comments

Comments
 (0)