Last active
June 13, 2024 01:52
-
-
Save gpsarkar/2b82fb69a0e58c3c76badf58ff800e59 to your computer and use it in GitHub Desktop.
Setup git repo on onedrive.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Go to onedrive folder in your pc and create a folder for git repository. | |
Usually onedrive resides in `C:\Users\%username%\OneDrive` | |
Open GitBash | |
cd ~/OneDrive | |
mkdir git | |
cd git | |
mkdir myproject | |
cd myproject | |
git init | |
git config --bool core.bare true | |
Now go to your workspace.. generally this will be any folder in your PC, outside of OneDrive.. | |
Never create your workspace in onedrive or it will save all the files from node_modules. | |
Lets say worspace is in D:\workspace | |
Open GitBash | |
cd D:/workspace | |
git clone ~/OneDrive/git/myproject | |
cd myproject | |
touch testfile.txt | |
git add . | |
git commit -m "initial commit" | |
git push origin master | |
Congratulation.. you have a private git repository on cloud. |
Hello, I don't know what was the goal in the first post, but the problem I reported is a condition that started only after the 08-09-2023 Windows 11 update. So, it is a bug created by that release.
In my case ANY .git folder in OneDrive is corrupted after the sync finnishes, so no matter how you create your Git repository, it will be corrupted after OneDrive syncs it with the cloud.
Such a problem does not happen in a Windows 10 computer I have connected to the very same OneDrive account. If a create my Git repository in my W10 computer, the repository will continue to work until I access it from my W11 computer.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got hung up on this for a while.
If you are starting from a working copy you copied to OneDrive you might get an error. Git doesn't like pushing changes to working copies because push only updates the repo, not the working files.
Convert the working copy to a bare repo by moving everything except the
.git
directory to a backup location. (Delete them if you're brave.) In the now mostly empty project root run the... core.bare ...
command from the OP. Now you can clone from and push to the "remote" repo.