Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How safe is "git" with an unreliable connection?

Tags:

I am using git for source control and push my changes to a repository on a server on the internet for safe keeping.

I can do some small amounts of coding on a laptop on a train, which has a wifi internet connection but it's not that reliable and occasionally drops out or becomes unusable slow. My question is what happens if my connection is lost during a "git push"? Will I end up with a corrupted or half updated git repository? And if so, how difficult is it to recover it?

like image 692
jcoder Avatar asked Aug 08 '10 08:08

jcoder


People also ask

Is it safe to use Git?

Here are the main reasons why Git is not secure: There are no authentication or verification measures. You can only control Git with server access. And developers can easily rewrite your change history.

Is Git encrypted?

git-secret encrypts files and stores them inside your git repository, providing a history of changes for every commit. git-secret doesn't require any extra deploy operations other than providing the appropriate private key (to allow decryption), and using git secret reveal to decrypt all the secret files.

Is Git online or offline?

Yes, you can use Git offline. Git only requires an Internet connection when you use commands such as git remote , git pull , and git push with a remote repository that is stored on an Internet server.

Which of the following in insist in Git safe?

Change the current working directory to your local project. Initialize the local directory as a Git repository. Add the files to your new local repository. Commit the files that you've staged in your local repository.


2 Answers

Git will not corrupt or "half update" your Git repository just because of a failed or slow connection. It's very robust and I would still feel comfortable using it even in the most arduous circumstances.

The actual push function is implemented in essentially two steps (in the case of a fast-forward push, which should always be the case):

  • upload all objects reachable from your current branch head and not reachable from the remote branch head
  • update the remote branch head to point to the latest commit

The first operation is idempotent, so if it fails for any reason halfway through, you can simply run it again to get everything up to date. The second operation is atomic and only happens once all the new objects are uploaded.

like image 86
Greg Hewgill Avatar answered Sep 21 '22 00:09

Greg Hewgill


According to Linus git is so well secured on the data area that it would even detect a memory error on the system it's running on. It will simply not apply the packets that arrive at the server that have an invalid checksum, so you have nothing to worry about.

like image 32
Blizz Avatar answered Sep 21 '22 00:09

Blizz