Hermetic Networks Hermetic Networks

Technicians - Git and GitHub - Session 08

Why Git and OneDrive Don't Mix

Two systems that both think they own the one true copy of a folder will eventually fight. This closing session covers what that fight looks like, where a repository should actually live on disk, and wraps up the course.

1Two systems, one folder, one job each

OneDrive, and SharePoint behind it, exist to keep a folder identical across every device and every person who has access to it, by watching for changes and syncing them to the cloud continuously, with no command required. Git exists to keep a deliberate, chosen history of a folder, recorded only when you decide a change is worth a commit. Both systems assume they are the authority over what the current state of a folder actually is. Point them at the same folder and that assumption collides.

2What the collision actually looks like

The hidden .git folder gets "helped"

Session 01 called .git the entire history of a repository, often thousands of small internal files. OneDrive does not know to leave it alone; it tries to sync every one of them, which is slow, and which can leave the folder in a half-synced state exactly while git is trying to read it.

Renamed "conflicted copy" files

When OneDrive sees the same file changed in two places before it can sync, its answer is to keep both, renaming one to something like notes-laptopname.txt. Git has no idea that file is related to anything; it is simply a new, untracked file, and the rename defeats the entire point of git's own, far more precise way of handling exactly this situation from session 05.

Files locked mid-write

OneDrive can hold a file open while it uploads, which is invisible almost all the time, except when git is in the middle of writing to that same file, which can produce an error or, worse, a corrupted write that looks fine until it doesn't.

Mangled line endings

Less common, but real: sync tools and git can disagree about how a line ending is stored, which can make git report every single line of a file as changed when nothing meaningful actually is.

3Where this repository actually lives, and why

This is not a hypothetical for Hermetic. This repository lives at C:\Users\jeff\Hermetic Networks\HN - Training. The OneDrive-synced folder on the same machine is a completely separate location, C:\Users\jeff\OneDrive - Hermetic Networks. That separation is deliberate, not accidental: putting the repository outside the synced tree means OneDrive never touches it, and git push and git pull remain the only way this project's files move between a laptop and anywhere else.

Check your own machine

If you clone this repository, or start a new one of your own, confirm where it lands. Anywhere under your OneDrive or SharePoint-synced folder tree, usually visible in File Explorer's sidebar under "OneDrive", is the wrong place. Anywhere else on the same drive is fine.

4Where a repository should live instead

Any folder outside the OneDrive or SharePoint sync tree works: directly under your user folder, a dedicated folder for projects, wherever you like, as long as no sync client is watching it. Git itself is the only synchronization this project needs. Push sends your commits to GitHub; pull brings in everyone else's. Nothing about that requires, or benefits from, a second system also trying to mirror the same folder in the background.

OneDrive - Hermetic NetworksSynced continuously,no git inside itHN - TrainingA git repository,outside the synced treeGitHub, reached only by push and pull
Two folders, two jobs, no overlap. The only path between the repository and anywhere else is git itself.

5How to tell you're already in trouble

  • A blue or green sync icon showing up on .git, or on the repository folder itself, in File Explorer.
  • A file suddenly named something like notes-DESKTOP-4F8K2.txt that you never created.
  • Git reporting an error mentioning index.lock, which usually means something, often a sync client, touched a file git was in the middle of using.
  • Every line of a file showing as changed in git diff when you know you only edited one.

If any of these shows up, the fix is the same one section 4 already describes: move the repository outside the synced folder tree entirely, rather than trying to make OneDrive and git coexist in the same place.

6Try it: check your own setup

  1. Open File Explorer and find any repository you currently work in, including your session 01 practice folder. Right-click its location in the address bar, or check the full path, and confirm whether it sits inside a folder named OneDrive.
  2. If it does, create a new folder outside OneDrive, for example directly under your user folder, and move the repository there using File Explorer, not by copying individual files.
  3. Reopen a terminal in the new location and run git status. If it reports cleanly, the move did not disturb anything; git only cares about the .git folder travelling with the rest of the project, which a normal folder move preserves.

7Check for understanding

  1. Why does putting a git repository inside a OneDrive-synced folder cause problems that a plain folder of documents does not have?
    Answer

    OneDrive keeps a folder continuously identical everywhere by watching for any change. Git keeps a deliberate history, recorded only through a commit you choose to make. Both treat themselves as the authority on the folder's true current state, and pointed at the same folder, those two models of "what just happened here" collide.

  2. A file named notes-DESKTOP-4F8K2.txt appears in a synced folder that you never created. What produced it?
    Answer

    This is OneDrive's own conflict handling: when it sees the same file changed in two places before it can sync them, it keeps both and renames one after the device that produced it. Git has no idea the two files are related, which defeats the far more precise conflict handling git already has, from session 05.

  3. Where does this repository, HN - Training, actually live, and why does that location matter?
    Answer

    It lives at C:\Users\jeff\Hermetic Networks\HN - Training, a location deliberately separate from C:\Users\jeff\OneDrive - Hermetic Networks. That separation means OneDrive never syncs the repository at all, leaving git push and git pull as the only mechanism moving its files between this laptop and anywhere else.

  4. git diff suddenly reports every single line of a file as changed, though only one line was actually edited. What does this session suggest checking first?
    Answer

    A whole-file diff with no visible conflict markers and no obvious explanation often points to a line-ending mismatch, something a sync client or a different tool can introduce, which makes git see every line as different even when the actual content is unchanged.

  5. A repository is currently sitting inside a OneDrive-synced folder and showing symptoms from section 5. What does this session recommend?
    Answer

    The fix is to move the repository outside the synced tree entirely, the same arrangement HN - Training already uses. Pausing sync only defers the conflict until sync resumes, and nothing about .gitignore or deleting .git addresses the actual cause, which is two systems both trying to manage the same folder.

8The course, in one page

SessionThe one thing to keep
01A commit is a complete snapshot. History never shrinks on its own.
02A push to main is the one trigger that rebuilds this site, and Entra is the gate in front of it.
03Status, add, commit, pull, push, in that order, as often as you like.
04A branch is your own line of work, untouched by anyone else's until you merge it.
05A conflict means two people had an idea about the same line. Read both, choose, move on.
06Branch is your test copy. Main is what staff see. Never swap that order.
07Private repo and Entra are two separate locks. Rotate a leaked credential; never just delete the file.
08Git and OneDrive both think they own the folder. Keep them in separate folders entirely.

From here, the way to get genuinely comfortable is the same as any other habit in this course: keep using the daily loop on real, low-stakes work until it stops feeling like a special event. The practice folder from session 01 is still there whenever a new command needs trying out somewhere with nothing at stake.

9Glossary

Sync conflict
The state where a cloud sync tool sees two versions of a file it cannot reconcile and keeps both, usually by renaming one.
index.lock
A file git creates briefly while writing to the repository; an error naming it usually means another process touched the repository at the same moment.
Line endings (CRLF / LF)
The characters marking the end of a line in a text file, which differ by convention between Windows and other systems and can cause a whole file to appear changed when only the line-ending style did.

10Sources

  • Microsoft, Fix OneDrive sync problems, Microsoft Support, including how conflicted copies are named.
  • Git, Pro Git, 2nd edition, the section on core.autocrlf, for how git handles line endings across operating systems.
  • Repository paths referenced in section 3 are this machine's actual folder structure, read directly, 2026-10-03.