🌐 Detecting your location…
📢 Advertisement — Configure AdSense in Appearance → Customize → AdSense Settings

كيفية إصلاح “القاتل: رفض دمج التواريخ غير ذات الصلة” في Git

⏱️6 min read  ·  1,213 words

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

$ git pull origin main
fatal: refusing to merge unrelated histories

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

$ git merge origin/main
fatal: refusing to merge unrelated histories

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

# ✅ Option 1: Force push (destroys the README commit — simplest)
git push -u origin main --force
# WARNING: Only use if nobody else has cloned the repo
# and you don't mind losing the GitHub-created README

# ✅ Option 2: Allow merge (keeps both, creates merge commit)
git pull origin main --allow-unrelated-histories
# Resolve any conflicts (often just README vs your code)
git push origin main

# ✅ Option 3: Rebase (cleanest linear history)
git fetch origin
git rebase origin/main
# Resolve any conflicts
git push origin main

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

# Add the second repo as a remote
git remote add other-repo https://github.com/user/other-repo.git
git fetch other-repo

# Merge allowing unrelated histories
git merge other-repo/main --allow-unrelated-histories

# All files from both repos are now in working tree
# Commit the merge
git commit -m "Merge other-repo into monorepo"

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

# Better approach: move the second repo's files to a subdirectory first
git fetch other-repo
git checkout -b temp-branch other-repo/main

# Move all files to a subdirectory
mkdir backend
git ls-files | xargs -I{} git mv {} backend/{}
git commit -m "Move to backend/ subdirectory"

# Merge back into main
git checkout main
git merge temp-branch --allow-unrelated-histories

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

# Check what happened
git log --oneline -5                    # your local history
git log --oneline origin/main -5       # remote history

# If you want to keep your local history (usually correct)
git push origin main --force-with-lease
# --force-with-lease is safer than --force: fails if remote has
# commits you haven't fetched (prevents accidental overwriting)

# If you want the new remote's history (abandon local)
git fetch origin
git reset --hard origin/main

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

# 1. Create repo on GitHub WITHOUT initializing (no README, no .gitignore)
# 2. Add remote and push
git init                              # if not already a repo
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/user/repo.git
git push -u origin main               # no conflicts because remote is empty

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

# Safe scenarios:
# - Initializing a project that was created with a README on GitHub
# - Combining unrelated repos intentionally into a monorepo
# - Recovering from an accidental repo recreation

# Unsafe scenarios:
# - You don't understand why the histories are unrelated
# - The remote was supposed to be a fork of your local (shouldn't be unrelated)
# - Two branches of the same project (investigate root cause instead)

git merge other-branch --allow-unrelated-histories

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

# See if two commits share ancestry
git merge-base --is-ancestor commit1 commit2
echo $?  # 0 = ancestor, 1 = not ancestor

# See all commit ancestry graph
git log --oneline --graph --all

# Find common ancestor (if any)
git merge-base branch1 branch2

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.
Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.
A: --allow-unrelated-historiesError 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.--forceError 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.
Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.
Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.git revert -m 1 MERGE_COMMIT_HASHError 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.git reset --hard HEAD~1Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.
Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.git merge origin/main --allow-unrelated-historiesError 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.git pullError 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.--forceError 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.--allow-unrelated-historiesError 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.Error 504 (Server Error)!!1504.That’s an error.There was an error. Please try again later.That’s all we know.

✍️ Leave a Comment

Your email address will not be published. Required fields are marked *

🌐 Read in:🇩🇪 Deutsch🇧🇷 Português🇸🇦 العربية🇮🇳 हिन्दी🇧🇩 বাংলা