Home > Mobile >  what is the advantage of using a remote repository like github vs. using git on a shared drive like
what is the advantage of using a remote repository like github vs. using git on a shared drive like

Time:10-28

I am new to github. And 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?

TIA

CodePudding user response:

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".

CodePudding user response:

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.

  • Related