Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT vs SVN : How is it different in terms of commit (in GIT) and just save the changes locally in the file (in SVN)

Tags:

git

git-svn

I want to know what difference(or rather advantage) does GIT gives when doing local commits (commit command) as compared to just saving the changes in the working directory in SVN when working offline (not connected to server)

I have read that GIT gives an advantage of working offline i.e. user can perform commits locally as many times as he wants to and then when the user is connected to the server, (s)he can push the changes to remote server. I would like to know why is it advantageous if all commit command does is just committing to local disk which is again same as just saving your changes to the disk in SVN (when not connected with the server) and not committing to project branch.

I like GIT but I am not able to understand this difference. Please help !!

Thanks, Nayan

like image 422
Nayan Soni Avatar asked Dec 01 '22 06:12

Nayan Soni


1 Answers

Scenario: You download the latest code from your repository onto your laptop before going offline (say for a long airplane journey).

On the flight you make some changes - you run units tests, run the code, everything seems to be working. You make some more changes - test them, things are still working. You get really enthusiastic and make a bunch more changes with some heavy re-factoring. You test the changes - everything's broken (e.g. because you made a bad assumption somewhere).

With SVN: Reverting the code to a working state is going to be tricky, because you can't remember how it looked before you started all that heavy refactoring. It'll likely involve a lot of tedious diffs between the code on your laptop and the master server whenever you get network access again. Meanwhile, you are stuck.

With Git: Assuming you were sensible and committed your changes to your local repository each time you knew it was in a working state, rolling back to the commit before you started that refactoring work is easy. You keep your valuable work and can start going down the right path straight away. When you get network access again you can push these changes to the master branch in one go and all will be well.

like image 118
raveturned Avatar answered Dec 04 '22 00:12

raveturned