I am wondering if it is a small group project which is stored on a shared drive and will never be published, is there any advantage of pushing to a Github repository?
-
1Approach the question from the reverse direction: Why *shouldn't* you use a free platform that's specifically designed to solve the problem of sharing repositories among groups of people? – Daniel Mann Oct 27 '21 at 15:54
-
Related: [Is it dangerous to put a Git directory in a drive sync tool?](https://stackoverflow.com/q/69056041/2745495) – Gino Mempin Aug 23 '23 at 21:58
3 Answers
I think there are two parts to this.
Firstly, what is version control, and why should you use it? Even if you are working alone, it is useful to have a record of not just what you changed, but why you changed it. If you are working in a team, it is useful to record who changed it, and to manage simultaneous changes without overwriting each other's work. And when you are testing code, and deploying it to a production environment, it is useful to track significant versions of the code.
Google Drive can record the version history of some files, but that only gives you the "what changed" from the above list. A dedicated version control system like git gives you all of the above and more.
Secondly, if git is stored as files, why can't I use Google Drive to share it? Although it is stored on the file system, it's best to think of the .git directory as a database; directly manipulating it is likely to lead to corruption, and potential loss of data. Sharing the files on Google Drive is likely to lead to exactly that: Google Drive doesn't know that two people are editing parts of a database, it thinks they're editing separate files which can be updated individually.
A service like Github doesn't just copy around the database files of your git repository, it uses an API (built into git) which allows you to safely copy data (i.e. your version history) between different databases.
On the other hand, you don't actually need a third-party service. You can very easily have a copy of git on a server which you treat as your own central copy. To be clear, I am not talking about a shared drive here, I'm talking about setting up a remote git server. Most people use a third-party service because it is a) easier than setting up and maintaining your own; and b) offers additional features in the web interface, such as code review via "Pull Requests"/"Merge Requests".
Using Git on a Google Drive could cause issues, as Google Drive will choose which version of the Git files to store, meaning you may lose some of your Git history in the process.
The benefit of GitHub is it's built for code, and has many nice features you'll likely learn to love once you give them a try. It might not seem worth it for a initial small project, but if you plan to code a lot more in the future, learning GitHub is almost definitely worth the time.

- 786
- 7
- 18
-
Does the issue with Google cloud you mentioned happen on other shared drive like OneDrive or Dropbox? – pingboing Oct 27 '21 at 16:57
-
@pingboing: yes: storing a repository in any kind of sharing service *inevitably* produces a corrupted repository. Sometimes the corruption is easy to fix, and sometimes it's much harder; don't do it. (The Git FAQ is being updated to note this as well.) – torek Oct 27 '21 at 20:47
What is the advantage of using a remote repository like Github ..?
It will actually work.
For git to work correctly it needs some way to guarantee the atomicity and order of operations. It can do this on local disk with lockfiles. It can do this when pushing to/pulling from remote servers because the protocols were designed to make it work.
There's no equivalent way to coordinate with Google Drive, Drop Box et al because they're designed to be "transparent" for ease of use.
For it to work you'd need one of:
- git knowing about the remote drive and communicating explicitly with its internal protocol, instead of treating it like a disk
- the drive mirroring software to infer that a directory is a git repo and actively monitor it for lockfiles
but neither are likely to happen, since a proper server is still better for the following reasons
You get proper permissions and commit attribution, because you're all authenticating to the server
You get a browsable, searchable online code repository with pull requests/merge requests, code reviews, etc.

- 64,155
- 6
- 88
- 132