views:

64

answers:

1

What are the most common ways of losing or having overwritten code when sharing a repository with another developer?

I say this after working with several share repos where magically a lot of my information disappears.

What are some safe workarounds?

I use Github.

+8  A: 

To solve this problem, you should be the only developper on your repository (or share it only with persons you trusts).

If someone else wants to contribute, he will clone your repository, make modifications on his own repository and do a "pull request".

You can verify this pull request and accept it or refuse it. So you have a full control of what is commited on your repository.


If only normal commits/push are done, you can always find your code looking the project history.

The only way to lose definitively informations on the repository is to force a conflicting push, erasing previous commits.


On GitHub, if you tag a version of your project, GitHub will create a zip archive of your project. This archive can never be erased (even if you force a tag modification: GitHub will ignore it).

So, you can protect your code by creating frequent tags. Even if you commit tree becomes erased, the tag archive will contain a save snapshot of your project.

Benoit Courtine