Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuances between other version control and GIT

Tags:

git

github

svn

I am very new to git. So please excuse me if my questions are silly and wrong.

Usually in other version controls like SVN, once you commit a file, it is safe in the repository. But in GIT when you commit a file the file is not moved to the repository yet. Instead, the file just resides in your local machine.[This is my understanding, correct me if am wrong please]. My questions are

  1. If your computer crashes after you commit the files, would you not lose the files that you have just committed and not pushed yet.
  2. If you have not pushed your files yet, then other developers will not be able to get the changes[by using a git pull] you have made and committed in your system.
  3. Considering the above questions, then why do people say GIT works perfectly fine even when you are not connected to the Internet? Until you git push your new/modified files, you are not sure that your files are safe, right?
  4. Can I say, SVN’s commit is equal to GIT’s push?

Please share your thoughts and thanks so much for your valuable time.

like image 270
Andy Avatar asked Mar 24 '26 22:03

Andy


2 Answers

in GIT when you commit a file the file is not moved to the repository yet

That is not entirely correct. You have to understand that you have a local repository. So when you commit a change (note that we commit changes, not files), that change/commit is moved to the repository: To your local repository. Yes, it is not in a remote repository yet but that’s entirely by design. You decide when you want to push that to somewhere else, or whether you want to allow other to even pull it (by giving them access to your local repository).

If your computer crashes after you commit the files, would you not lose the files that you have just committed and not pushed yet.

Depends on the kind of crash: If you lose your hard disk, then that’s probably true. In other cases no; you can still access your local repository and the commit is safely stored there.

If you have not pushed your files yet, then other developers will not be able to get the changes

Yes, that’s by design. Committing and sharing changes is separated.

why do people say GIT works perfectly fine even when you are not connected to the Internet? Until you git push your new/modified files, you are not sure that your files are safe, right?

Because a version control system is not a backup storage. Yes, you can utilize it as one but that’s just a side effect. If you are using it as a backup, then it’s likely that you are using it in the wrong way.

A version control system exists to keep track of the changes you make. Ideally, you make the commits in such a size that they contain only one specific (semantic) change, e.g. one feature, or one bug fix, so it’s clear what changes relate to each other and what every change is supposed to do. And that’s exactly where a distributed version control system helps: You are not required to have access to the internet, to your remote repository; you can commit those changes regularly in small commits to your local repository, without having to care about how well your internet connection is, whether your server is up, or how long this will take. Since you are committing locally, it’s all instant and never fails.

And only when you are done with something and you want to publish it, you push it to a shared remote repository.

Can I say, SVN’s commit is equal to GIT’s push?

No, because they are fundamentally different. Subversion’s commit takes your local changes, and checks those into your repository now. You have no control about what gets checked in when, and you are completely dependent on the Subversion server.

A push in Git just transfers existing commits you have in your local repository to the remote repository. It’s an exchange of fixed and existing information which integrity is also secured.

like image 145
poke Avatar answered Mar 27 '26 10:03

poke


The Git is a distributed version control platform and it does not need a central always-online remote repository to work.

So the answer to your first three questions is YES. Other developers will not see your commits and contributions to the code, untill you first commit them and then push.

About your last question on comparing SVN Commit and Git Push, I would say that yes, they are both conceptually the same thing.

like image 33
Farhad Faghihi Avatar answered Mar 27 '26 12:03

Farhad Faghihi