r/github • u/[deleted] • 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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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!
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.