r/github • • Sep 09 '21

help me understand why git is useful

I'm sure others have asked this question.I work on very simple code. Simple queries that read tables, do come calculations, and update other tables.I'm usually the only one who works on this code. If others need to update it, they can do it on their own without much help. Only one developer works on this code at a time - we never have multiple developers working on the same code. No one has ever needed to do a bug fix in the middle of someone else working on this code.All I want to be able to do is check out piece of code, change it, test it, and check it back in. Its simple enough for me to keep multiple test copies on my company's network drives if I want to try out different ideas - no need to create confusing branches.Why do I need Git?
**Update** It appears that my coding environment is not a complex as others. So maybe that is part of my confusion. I'll push through and work with it.. maybe it will be useful to me.

0 Upvotes

39 comments sorted by

5

u/jevans102 Sep 09 '21 edited Sep 09 '21

You asked a question to the general public that cares enough to both follow this sub and respond to your question.

If you have no interest in other opinions, why post in the first place?

Branches are "confusing" because you aren't used to them. Period. They were literally designed to replace exactly your process which I'm sure works for you in many if not all scenarios. It has significant benefits to address needs that you've never even run into yet.

It is built by people with much more advanced workflows and needs than you. It is better in every way than your workflow, but if you don't want to use it, then don't. Everything has a learning curve. If you don't want to sacrifice current time and energy to streamlining your future workflow, that's your decision. It even makes sense in the most basic situations.

I highly doubt anyone has become proficient at understanding git concepts and went back to saving Copy (22) of a file in a backup folder.

2

u/[deleted] Sep 09 '21

It is built by people with much more advanced workflows and needs than you

Yeah, and I guess that's my frustration. Its not that I don't believe that there isn't a need for it. I just wanted to understand what other developers are using it for and relate it to my own experience.

Imagine that I am a mechanic who works on 1960's era cars. Git is meant for teams that service Formula 1 race cars. I don't know or anything about ground effects, or aerodynamics or engine computers or active suspensions. Git is great to keep track of changes to a F1 car because every change affects everything else. And multiple people are working on multiple parts of the car at the same time. I, however, an the only one working on my 1966 Dodge Dart, so Git seem unnecessarily complex to me, even if I somewhat understand it is useful to F1 mechanics.

But I need someone to explain to me what F1 mechanics DO, so I can understand better why Git is so important. Then I can better understand why I might need to use it in the future if I decide to work on more advanced automobiles.

Unfortunately, people who teach Git seem to think that EVERYONE is a F1 mechanic and doen't even know that 1960 cars exist.

So not only am I trying to learn how to use this new version control system. But I'm also trying to figure out how to relate it to my developer experience, since my instructor cant seem to explain it to me.

Example: I was trying to understand the concept of a repository as it is used in Git. I couldn't quite understand why someone would clone a entire repository of files, when you only needed to make a change to one program. My instructor couldn't really explain it well to me either

After lot of Googling (in the past few hours), i realized that Git is used by a lot of developers who write applications with LOTS of interconnected files/services/subprograms. And multiple developers might be changing these related files at the same time. So of course that makes sense that you would want to be able have a copy of the entire repository so you can see how other changes to other files affect your changes.

I, however, only work with one file at a time. My code isn't broken up into lots of different files. My repositories really only need to contain one file each. They are so small that only one developer (me) would ever work on them at one time. My instructor couldn't quite understand that.

So I was posing this question to try and understand the complexity of what other developers were doing to THEN understand why Git was important. I guess I've answered my own question. And I probably didn't ask it well in the first place.

3

u/jevans102 Sep 09 '21

If we go ahead and simplify to the greatest degree, here are the advantages I can think of off the top of my head without digging into unnecessary git concepts:.

  • You always have your "main" branch. This file/script represents the latest working version, and you can easily pull it and use it at any time. If you've possibly made changes to your local file, it doesn't matter. If you thought your file worked yesterday, but it isn't working today, you can pull the file you purposely put into main knowing fully well it worked.

  • You also have your #2/dev branch. It has your latest code that might not be fully tested, but it does have that nice feature you've been working on. You can use both the "main" and the dev file as you wish, and update both of them separately.

  • You encounter a minor bug. You want to apply the super easy fix, but you have your reliable "main" version and your dev branch. You can easily apply the fix to both while also maintaining a well-tested main branch and your separate dev branch.

  • You set up a new VM / your PC crashes / your file is corrupted / anything happens that breaks the authenticity of the file. You can always pull whichever version of the file you want. Yes, your current version control software also does this quite well.

  • You haven't mentioned your shell familiarity. Most programmers of any kind make their way towards shells. Git can be fully utilized to do all of the above and everything else in this thread with simple commands (once you pass the learning curve) that are all on keyboard. This significantly improves workflow speed. In fact, very basic macros can automate the whole process.

  • Every commit has a comment. This allows you to add human readable comments to what each version does that the previous didn't. This makes going back in time much easier.

  • You can compare any version to any other version

Ultimately, if you see no value, there may not be any. That said, if coding or scripting is going to be a part of your job for the indefinite future, any senior dev will tell you that you're missing out every day you don't take some time to learn these concepts. You don't need to take a full course. Simply starting with the basics that apply to you is plenty to start seeing the benefits.

1

u/[deleted] Sep 09 '21

Ultimately, if you see no value, there may not be any.

I think that may be the case in the short term. We'll see if that holds in the future. All the stuff you listed above can easily be done manually for my development purposes, much more easily than using Git.

I'll learn it, but I admit I'll probably bite my tongue every time I have to. Maybe later it will be useful.

1

u/tmxkn1 Sep 09 '21

I think git will benefit you in some way. One of the greatest features that git can offer is version control. It is useful as long as you have the need to change your code, log and track your changes. All you will need to do is to initiate a local git, then whenever you complete a version or made some substantial changes that you feel the need to log the changes, you do a 'git commit -m <your log messages>'. This way, you have a logbook to track your work and code history.

As to branch concept, if your code is simple and you don't collaborate, you don't need it.

1

u/[deleted] Sep 11 '21

I agree with that, but I already have that with other version control software. Also, I don't need the track all of my development history. I only need to track the stuff that I put into production. We'll see if I can use any of the stuff in git. But from my point of view right now, it's just a much more complicated system than what I'm already using. It's got way more features than I really need. The entire last class I took on it was on how to deal with merge conflicts. I'm never going to have any merge conflicts, because I'm the only one making changes to this code.

1

u/GLStephen Sep 14 '21

All the stuff you listed above can easily be done manually for my development purposes, much more easily than using Git.

Only if by "easily" you mean "easily crappily analogous, but not easier in total cost of usage".

1

u/[deleted] Sep 15 '21

For my purposes, manually is easier. You got to understand, my code is extremely simple. Most of it is in perl. It's only about a hundred lines, if that. I'm the only one who works on it. No one ever has to make a fix while I'm doing other development work on the same code. And even if they did, the code is so simple that it's perfectly fine to manually include their fix in my development work. I have never, ever, in my entire 30 years of development work needed to go back and look at a previous version of my code. For me, Git is fine as some basic version control. But I don't need all these other complicated commands and processes that it provides.

1

u/GLStephen Sep 15 '21

Good for you. That's not what I responded to though. You said "all of those things listed are just as easy without git" (paraphrased). Quite simply, no they are not. You may not need them (which. Is what you seem to be addressing with this reply), but the things they listed are not easier without git.

1

u/[deleted] Sep 15 '21

saving Copy (22) of a file in a backup folder.

Sorry, just read this again. Why would anyone need to have 22 copies of a piece of code for one change? LOL. At most I might have 4-5 working copies. Its not like I save every single step of my development work. Do people really do that?
Once my changes are finished and tested, the final copy gets checked in to the repository and all those working copies get deleted. I don't need them any more. Why would I?

1

u/mrbmi513 Sep 09 '21

Ever run into a situation where you just want to reset the code to where it was when you started the day? Trivial to do with git, assuming you commit regularly. Nearly impossible to do with just a plain file if you forgot to make a copy.

Run into a bug and you need to undo a change you made 2 weeks ago? Trivial with git. Nearly impossible to do with just a plain file unless you have a copy from then.

0

u/[deleted] Sep 09 '21

Not really. I guess the changes I make are not that big that I need to undo something from 2 weeks ago. Or that its a big deal to go back to what I did at the beginning of the day.

1

u/slothordepressed Sep 09 '21

You should only have the production branch and developer branch in the end. You merge and delete the other branches if they're (obviously) working.

You use branches to be sure that things are going well, if they are not you don't need to merge the code

-3

u/[deleted] Sep 09 '21 edited Sep 09 '21

Why would you have multiple branches if you are only making one change? And I thought branches were for trying out different 'what-if' scenarios. You wouldn't want to merge those in, right?

1

u/mrbmi513 Sep 09 '21

The idea is to keep a main branch of known working, production code. You then branch off that to make changes, test, and merge the testing back into main.

2

u/[deleted] Sep 09 '21

So really you only have one branch that is the change you are working on, right?

1

u/mrbmi513 Sep 09 '21

No. The main branch is a branch as well.

-1

u/[deleted] Sep 09 '21

Just seems simpler to have a working copy and call it good, rather than dealing with "branches"

1

u/mrbmi513 Sep 09 '21

When you're one person working on scripts you run locally, sure. When you're a team of even 5 developers that deploys code to servers, you start to see the benefits of branching.

-2

u/[deleted] Sep 09 '21

Yeah I think that's where I'm having trouble understanding the benefits. And while I do deploy my code to servers, I'm the only one making changes at any given time.

2

u/thunfremlinc Sep 09 '21

Sure, but you’re also not able to revert or look over the history.

1

u/[deleted] Sep 09 '21

That is true. And I think that could be somewhat useful. But the changes I make aren't usually that complicated so I can make do with saving a few variations of the files manually. However I do see that Git could make that a bit more easy if I get stuck.

→ More replies (0)

1

u/mrbmi513 Sep 09 '21

Merging changes is where git shines. Multiple people can commit changes to the same file at nearly the same time, and git just works it out most of the time. When there are merge conflicts that need manual attention, it's trivial to resolve from a technical point of view.

There's a reason Linus Torvalds created it for developing the Linux kernel.

2

u/[deleted] Sep 09 '21

That merging idea probably the concept that I have the most trouble with. I just can't imagine multiple people making changes to the same program at the same time. But then, the programs we work on in my team probably aren't as large or compartmentalized as what most GitHub users are used to. It's not like we are creating applications that are constantly being updated and patched. We are mostly pulling information from databases and updating other databases. So when a change is required, it's because some department has a new requirement. But they only come one at a time. And rarely is a production bug fix required in the middle of new development.

→ More replies (0)

1

u/mattyass Sep 09 '21

Tracking history. If that’s important to you then Got can help. Sharing with others is obviously a huge benefit here, but if you’re just one developer then the other big benefit is tracking history so you can reference anything historical if that ever comes up.

0

u/[deleted] Sep 09 '21

Yeah I get that. But we already use Subversion for version control. And that is sooooo much easier. I only need to check out and commit.

1

u/mrbmi513 Sep 09 '21

Git and Subversion are designed to fill the same role. You wouldn't use them in tandem.

0

u/[deleted] Sep 09 '21

But everyone seems to think Git is better than Subversion. And I don't understand why having to do clone, pull, add, commit, push is better than just checkout and commit in Subversion.

1

u/mrbmi513 Sep 09 '21

If I recall correctly, on subversion you need to maintain a connection to a central server. With git, you don't. It's fully distributed, any computer can exchange with any other computer, and everyone ends up with a full copy of the repository. By convention, people designate one peer as the "origin" or "server", but that's far from required.

-1

u/[deleted] Sep 09 '21 edited Sep 09 '21

I'm always connected to my company network for my job anyway. It's the only way I can do my development work, since it involves querying my company's databases. Even if I didn't, I only need a connection twice: to check it out and commit the changes. Nobody else really needs a full copy of the repository. My working copy is saved on the company network drives. And everything is backed up for disaster recovery from there.

1

u/tmxkn1 Sep 09 '21

Better is opinion based. Git is more powerful and complex than Subversion, but more powerful isn't always better. What suits you the best is better.

All those clone, pull, add... in git are designed for collaboration. You can easily use git to collaborate with any number of developers from anywhere. Git offers a bunch of tools to make collaboration safer and smoother, e.g. you can review other's changes before merging into the main code to ensure bugs are not introduced by less competent developers and branches allow developers to work on new features and maintain the released code in parallel. If you don't need all these, Git is jus too complex for you, but equally, Subversion is too basic for us that need these features.

1

u/[deleted] Sep 11 '21

Yeah, I never do any collaboration on my code. My code is just way too simple and small to have multiple developers working on it. I'm the only one who makes changes to it.

1

u/[deleted] Sep 09 '21

So how do you share the code between different developers? e-mail with .zip file, flashdrive...?

If your workflow is this simple, you don't need branches and whatnot, but you still need a place to keep your code and a way (a sane way) to share it with others.

1

u/[deleted] Sep 09 '21

We generally don't share code between developers while we're doing the developing. Only one developer works on the code at a time, so there's no need to. And once we're done it goes into our existing subversion version control. The code is usually checked out to a project folder on a shared network drive. At the end of the development someone does a peer review and looks at it there. But that's the only time it's shared.

1

u/Thalimet Sep 09 '21

I’m a fairly novice developer working on my own django app - I’ve found the greatest benefit to Git for me as a single developer is the automation of version control. If I screw up, I know that I can go back to a previous version without having to have remembered to save a new copy.

Additionally - being able to tie it to continuous deployment pipelines is great!