What Is a .ORIG File?
A .orig file appeared next to a file you edited. A tool saved the original before changing it — often during a patch or a Git merge. Here is what to do with it.
What a .orig file is
A .orig file is the original, unmodified copy of a file that a tool saved as a safety backup before changing it. The two overwhelmingly common sources are Git merge conflicts and the patch command: both write filename.orig next to the file so you can compare against the version from before the change. It is not a special format — it is a plain copy of whatever the file was (code, text, config).
Why you suddenly have one
During a merge, rebase, or patch, the tool rewrote your working file and preserved the pre-change state as .orig in case you need to review or revert. If you just resolved a Git conflict with a merge tool (kdiff3, meld, Beyond Compare, VS Code’s merge editor), that tool is the usual culprit — Git’s mergetool keeps a backup by default. You will typically see files like main.js.orig, index.html.orig, or config.yml.orig.
How to open a .orig file
Ignore the .orig extension and open the file in the same editor you use for the real file (VS Code, Notepad++, Sublime, vim). If your editor won’t syntax-highlight it, make a copy with the extension removed — cp main.js.orig main-old.js — and open that. To see exactly what changed between the backup and the current file, diff them:
diff main.js.orig main.js
# or, side-by-side and colored:
git diff --no-index main.js.orig main.js
How to recover lost lines after a bad merge
This is the one case where a .orig file is genuinely valuable. If a merge or patch clobbered code you wanted to keep, the .orig is your snapshot of the file before the change. Diff it against the current file, copy the missing lines back by hand, or in the worst case restore the whole thing:
# inspect what the merge removed
diff filename.orig filename
# restore the pre-merge version entirely
cp filename.orig filenameDo this before you delete any .orig files.
Is it safe to delete?
Yes — once your merge or edit is finished and the working file is correct, .orig files are pure leftovers and nothing in your project needs them. They are not tracked by Git unless someone accidentally committed them. Clean them up in bulk once you have verified your changes:
# macOS / Linux — delete every .orig under the current folder
find . -name '*.orig' -delete
# Windows PowerShell
Get-ChildItem -Recurse -Filter *.orig | Remove-Item
Stop Git from leaving .orig files
If you never want the backups again, tell Git’s merge tool not to keep them:
git config --global mergetool.keepBackup falseAnd add a line to your project’s .gitignore so stray backups never get committed:
echo '*.orig' >> .gitignore
Common problems
“I can’t find the .orig file.” Git only creates it when you resolve a conflict through git mergetool; a plain text-editor resolution leaves none.
“A .orig got committed to the repo.” Remove it with git rm --cached filename.orig and add *.orig to .gitignore.
“Hundreds of .orig files.” Safe to bulk-delete with the commands above once your builds pass — they do not affect the working tree.
FAQ
How do I open a .orig file?
Open it in the same text or code editor you use for the real file — it is the original file's plain content. If it won't highlight, copy it with the .orig removed and open that copy.
Is it safe to delete a .orig file?
Yes, once your merge or patch is done and the working file is correct. .orig files are leftover backups your project does not need.
What creates .orig files?
Git merge conflicts resolved through git mergetool, and the patch command, both save filename.orig as a backup of the pre-change version.
How do I see what changed vs the .orig?
Run diff filename.orig filename, or git diff --no-index filename.orig filename for colored side-by-side output.
How do I recover code a merge deleted?
Diff the .orig against the current file to find the removed lines, then copy them back — or restore the whole file with cp filename.orig filename. Do this before deleting any .orig.
How do I stop Git from creating .orig files?
Run git config --global mergetool.keepBackup false, and add *.orig to your .gitignore so stray backups never get committed.
Can I delete all .orig files at once?
Yes. On macOS/Linux use find . -name '*.orig' -delete; on Windows use Get-ChildItem -Recurse -Filter *.orig | Remove-Item, after verifying your changes.
Other file types explained
- Is a .crdownload File Safe to Delete? (Unfinished Chrome Downloads)
- .swp vs .swo — What's the Difference? (Vim Swap Files)
- Are .bak Files Safe to Delete? (Backup Files)
- "Found a Swap File by the Name" in Vim — What It Means and How to Recover
- Microsoft Edge Download Stuck or Not Finishing — How to Fix It
- Recover an Unsaved File in Sublime Text After a Crash
- Recover an Unsaved File in VS Code After Closing or a Crash
- Recover an Unsaved nano File: What the .save File Is & How to Use It