The right way to do this is use git-remote-dropbox: https://github.com/anishathalye/git-remote-dropbox
Creating your own bare repo in Dropbox causes a lot of problems. Anish (the creator of the library) explains it best:
The root cause of these problems is that the Dropbox desktop
client is designed for syncing files, not Git repositories. Without
special handling for Git repositories, it doesn’t maintain the same
guarantees as Git. Operations on the remote repository are no longer
atomic, and concurrent operations or unlucky timing with
synchronization can result in a corrupted repository.
Traditional Git remotes run code on the server side to make this work
properly, but we can’t do that.
Solution: It is possible to solve this properly. It is possible to use
Git with Dropbox and have the same safety and consistency guarantees
as a traditional Git remote, even when there are multiple users and
concurrent operations!
For a user, it’s as simple as using git-remote-dropbox, a Git remote
helper that acts as a transparent bidirectional bridge between Git and
Dropbox and maintains all the guarantees of a traditional Git remote.
It’s even safe to use with shared folders, so it can be used for
collaboration (yay unlimited private repos with unlimited
collaborators!).
With the remote helper, it’s possible to use Dropbox as a Git remote
and continue using all the regular Git commands like git clone, git
pull, and git push, and everything will just work as expected.