My team is trialling the use of Sharepoint Online and Teams to replace a public network drive for our docs and work files. I'm running into a problem when trying to use git: creating the repo with git init works, but adding and committing files fails with an error:

fatal: cannot use .git/info/exclude as an exclude file

The repo in question is a very simple one, just 4 small files in a directory a couple of levels down from the root.

Are there known problems with using git on a shared document library, mapped as a network drive? I had a look at the list of limitations, and it doesn't seem like there should be problems.

At a previous job I had git repos in my OneDrive for Business, and it mostly worked fine (although I ran into intermittent sync glitches).

  • The .git directory does seem to be created correctly; I can see it both in Explorer and in the SPO docs library in the browser. The .git/info/exclude file is there as well
    – Hong Ooi
    Mar 4, 2021 at 4:02

2 Answers 2


I would recommend using Azure DevOps or GitHub to host your repositories rather than a SharePoint document library. Microsoft recommend syncing SharePoint document libraries using the OneDrive for Business application rather than mapping a library to a network drive.

  • The use case is not that people are hosting repos in Sharepoint, but rather cloning them from Github/ADO/etc. In any case, it looks like using OD for Business is the better route
    – Hong Ooi
    Mar 25, 2021 at 1:20

1.Add your SharePoint as windows drive in ms dos command prompt using below command.

net use z: https://xxx.xxx.com/xxx/xxx

2.Navigate to z drive and create a repo folder.

cd z:

makedir proj1

3.Create git repo

git init --bare

4.Navigate to local folder.

cd ”c:\repo"

5.Clone SharePoint repo in local folder.

git clone file://z:\proj1

  • A bare metal repo shouldn't be available for usage from within a SharePoint document library.
    – Dennis
    Mar 20 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.