Live data from Hacker News

Moving from SVN to Git in 1,000 easy steps

codeascraft.etsy.com

21–30 of 70 posts

Re: Moving from SVN to Git in 1,000 easy steps

#21
post #14
post #13

Earlier quoted context omitted.

For one, you can have much more atomic commits, which can help with maintaining the code and finding and fixing bugs. Just push all of your small commits at the end of the day. Another benefit I've found--as a student with an internet connection that isn't always on--is that I can still commit without it. It's also much easier to use branches in Git. If I want to try something weird, or temporarily break some code, i…

Thanks for your comment, its the other schemes beyond a centralised workflow that I have not arrived at yet, as I'm new to Git and not finding it friendly so far (despite years of experience with other systems), I probably just don't get it yet ;-)

Forget the centralized/decentralized stuff. At some point almost all git users have a somewhat centralized model.

You say you don't get it yet and I think it's the issue. Coming from years of SVN I was in more or less the same situation (but I choosed to switch so it was obviously less painful). Then I started playing with local branches and funny stuff like that. I can assure you that once you get yet you'll never wan't to go back :)

Re: Moving from SVN to Git in 1,000 easy steps

#22
post #5

Speaking as a long-term Subversion and Perforce user, I'm finding the switch to Git (forced on me by a job change) painful. My old work flow: 1. Commit my code to the central repo. My new and "improved" Git workflow: 1. Commit my code to my local branch. 2. Push my local branch to the central repo. As we're using Git as a centralised source control anyway, what is this extra work saving me over using a "traditional"…

Git is very, VERY commonly used in a "centralised" manner, so don't worry about that. Once you're used to git, the overhead of having to commit and push whenever you would have just commited in svn is minimal. Still, it will always exist - so the question is "what do you get in exchange"? There's two major things:

First, the two step process lets you perform commits CONSTANTLY on your local repo. Coming from svn, it may take a little bit to figure out why this is good, but trust me, it is. In svn you (typically) are careful about checking in half working code into the central repo. And rightly so; people are (often) relying on the trunk code to be working. You don't want to break the build, right? But anyone who has done non-trivial work with svn will, sooner or later, lose some work that wasn't "ready" to check in. In retrospect, it feels kind of weird to have source control that you aren't supposed to use...

Second, everyone knows that git has strong support for branching. But developers used to svn don't always "get" is that git has REALLY strong support for branching. As in, you should be using it. Right now. Constantly. Are you about to start work on a new issue? Branch. Got a new idea on how to solve that problem? Branch. Unsure if you should branch? Branch. Feeling bored? Branch twice. Okay, I'm exaggerating a little, but only a little. You really should be doing everything in branch, because it's very VERY easy to merge, swap branches, pull changes between branches, shelve a branch and start over, stop working on a branch, restart work on a branch, and generally do whatever you want. Again, anyone who has done non-trivial work with svn will have probably learned that branches are a cunning trap for the unwary - you need to unlearn that. :)

I'm sure there are teams out there using git in a "truly" decentralised manner, but in my experience the point of git (and any other dvcs) is actually that it makes a centralised workflow much less painful for the individual devs.

Re: Moving from SVN to Git in 1,000 easy steps

#23
We had an entire orgs source-code in one SVN repository. It was useful for moving files from one project to the next to keep history and enabled anyone in the org to easily commit to any project.

Obviously that wasn't scalable. (My inbox of commit log emails was insane.) So we transitioned to git. Plus, most of the engineers were already using git-svn. It just took someone who had a free weekend to "git svn clone" and move everyone over to that.

It was PAINFUL at first. I was one of the grumpy people, but after I got the hang of git, I am so glad we just ripped the bandaid off.

Re: Moving from SVN to Git in 1,000 easy steps

#24
post #5

Speaking as a long-term Subversion and Perforce user, I'm finding the switch to Git (forced on me by a job change) painful. My old work flow: 1. Commit my code to the central repo. My new and "improved" Git workflow: 1. Commit my code to my local branch. 2. Push my local branch to the central repo. As we're using Git as a centralised source control anyway, what is this extra work saving me over using a "traditional"…

This is like asking "what's the advantage of driving an Audi S5 over a model T, don't they both get you from point A to B?"

Git is a far more advanced tool compared to SVN. It will enable you to do things that SVN is not capable of, and it will save you from trouble that would have resulted in a multi-day firedrill in SVN.

For example, with Git you can maintain local history on your desktop quite easily. Since there won't ever be conflicts, committing is effortless. But now you have the ability to rollback to a previous state quite easily, far beyond the ctrl-z capabilities of your favorite IDE.

Also, in general with Git merging your changes into the central repo ought to be easier than it was previously. If there are conflicts they'll be easier to sort out, for example.

Re: Moving from SVN to Git in 1,000 easy steps

#25
post #5

Speaking as a long-term Subversion and Perforce user, I'm finding the switch to Git (forced on me by a job change) painful. My old work flow: 1. Commit my code to the central repo. My new and "improved" Git workflow: 1. Commit my code to my local branch. 2. Push my local branch to the central repo. As we're using Git as a centralised source control anyway, what is this extra work saving me over using a "traditional"…

In the basic use case (changes into a central repo), git and svn look similar. Git's power is revealed when you realize how it tracks changes individually -- it's super easy to branch and move changes around. The decentralization isn't just on a team level, it's on a per-developer level.

Let's say you have 3 bugs to fix. In SVN you might work on them 1 at a time (start to finish -- hopefully no blockers!), or descend into madness and try to work on all 3 simultaneously. In git, you'd make 3 branches and work on each separately.

Oh, a hotfix came along while you're halfway through a bugfix? In SVN, you cringe: do I manually copy my changes somewhere else and revert? Ugh.

In git, you just make another branch from your clean master, do the hotfix, and pull that change into your bug branches at your leisure. In svn, this branching is theoretically possible, but not used practically -- they are too cumbersome and manual (you need to track what changes went where, and could accidentally apply them twice).

I've written more about it here, if you're interested:

http://betterexplained.com/articles/intro-to-distributed-ver...

Re: Moving from SVN to Git in 1,000 easy steps

#26
post #5

Speaking as a long-term Subversion and Perforce user, I'm finding the switch to Git (forced on me by a job change) painful. My old work flow: 1. Commit my code to the central repo. My new and "improved" Git workflow: 1. Commit my code to my local branch. 2. Push my local branch to the central repo. As we're using Git as a centralised source control anyway, what is this extra work saving me over using a "traditional"…

The thing I notice is that you weren't using branches with Subversion.

For about 4 years now, I've been doing branch based iterative development. This is a great way for a team of engineers to work together and have a continuous release process.

Meaning, you deploy trunk and do development on 'iterative branches' (ie: you have branches called iteration-0001, iteration-0002, iteration-0003, etc...). All works happens on the iteration branches which are then tested and merged to trunk on a regular basis as part of the release process. If you have work that spans more than one iteration, you make a branch off the current iteration.

Unfortunately, subversion has a very hard time keeping track of development that way. The reason is that if you (and your co-workers) want to work on another branch off of the iteration branches (so you don't hold up a release), then merging changes from the iteration branches into your branch become a nightmare because merge tracking on your branch has no way to know what is happening on the other branches. If you don't do it right, you can end up with a branch that can never be merged back.

The way merge tracking is handled is a central design failure of Subversion. I made a long blog posting about this a while back: http://lookfirst.com/2011/04/subversion-mistake.html

Git handles all of this beautifully.

So, while today, you might not need the extra functionality of git, it is good to have a tool which can support your needs in the future.

Re: Moving from SVN to Git in 1,000 easy steps

#27
post #15

You guys laugh but migrating version control systems can be one of the most nightmarish projects an organization chooses to undertake. It's right alongside rewriting mainframe software (that probably has been working for 20 years) and an overhaul of the employee HR systems. It's scary. It's fraught with pitfalls. But in the end everyone hopes the result is a better tool. We need more of these writeups. I personally l…

It's best to think of Git not as a version control framework but as a library of functions on a directory-tree data structure (edit: with a history). With this mental model, you realize that 1) there's all kinds of crazy things you can do 2) for a given crazy thing someone's probably already done it, and if it's not too far-out there's probably a command for it. The reflog makes uncollected garbage available to the u…

> on a directory-tree data structure

Or on a directed acyclic graph of refs; that's the definition that made everything click for me.

Re: Moving from SVN to Git in 1,000 easy steps

#28
post #5

Speaking as a long-term Subversion and Perforce user, I'm finding the switch to Git (forced on me by a job change) painful. My old work flow: 1. Commit my code to the central repo. My new and "improved" Git workflow: 1. Commit my code to my local branch. 2. Push my local branch to the central repo. As we're using Git as a centralised source control anyway, what is this extra work saving me over using a "traditional"…

I've come to see the key distinction between git and SVN as:

* Old workflow: "commit code" and "share code with team" are jumbled together.

* New workflow: "commit code" and "share code with team" are separate actions.

This looks so obvious, but coming from years of using SVN, it took me a while to understand the implications. With git I could fix (with commit --amend) those embarrassing "whoops, forgot to add an untracked file" kinds of mistakes. Over time, I found that my local commits became smaller and more frequent because I can reorder and squash them before pushing (or git-svn dcommitting, as most of my clients run SVN).

Consider a larger change where you might implement it one way, decide you were on the wrong track, back off a bit and implement it some other. With SVN these false paths are either in the common repository confusing the history, or I'm in a disconnected state for an uncomfortably long time. With git, all these changes are local commits that are ultimately kept out of the main history because I've reordered the change history into something comprehensible.

It took me a few months to grok git. Reading an article on the filesystem structure of the repository helped me a great deal.

Re: Moving from SVN to Git in 1,000 easy steps

#29
post #5

Speaking as a long-term Subversion and Perforce user, I'm finding the switch to Git (forced on me by a job change) painful. My old work flow: 1. Commit my code to the central repo. My new and "improved" Git workflow: 1. Commit my code to my local branch. 2. Push my local branch to the central repo. As we're using Git as a centralised source control anyway, what is this extra work saving me over using a "traditional"…

You may be doing it "wrong".

My old Perforce workflow: code, code, code, code, code, code, code, code, commit

My new Git workflow: code, commit, code, commit, code, commit, code, commit, code, commit, code, commit, push

It's the difference between single-piece flow and large-batch production in Lean Manufacturing.

Re: Moving from SVN to Git in 1,000 easy steps

#30
post #8

Earlier quoted context omitted.

The moral of any story involving SVN is: "Switch from SVN".

Don't live in a black and white world.

Indeed. SVN is far from the worst source control system out there, and even as we move on to better once, it's pointedly the system that got a lot of coders into using source control.
Post reply on HN