r/learnprogramming • u/Szahu • Apr 16 '21
Resource You should learn git ASAP, and here's why.
Do you ever have to comment out a whole bunch of code to try something different? Or perhaps you changed some things and your code does not run anymore? Or maybe you want to work on your project from many devices? Or do you want to use free static website hosting for your CV/projects?
If answer is yes to any of these questions, you most certainly need to learn how to use git/github.
To anyone who doesn't know what git is: It is a 100% free tool aimed to version control your code. It has a lot of use cases but most importantly it is used to work on different branches of a project. Let's say you want to add a feature to your project, so you create a new branch which copies all the code from the main one. Then you work on that branch, consequently implementing your feature, meanwhile your code on main branch remains intact. Once the feature is ready, that new branch is merged with the main one adding the feature. No commeting things out to try something different. No lurking and searching for bug caused by changing your code. The working main branch is always there to go back to.
It seems very intimidating at first but once you understand fundaments it is actually easy to grasp and you only need to know a couple of commands to solve issues I mentioned above.
Github is an online service where you can store your code, not only it's present state but it's history and all the branches. It also provides free hosting service for static websites and much more.
Using git really makes working on projects easier and can save a lot of headache, so start using it asap.
Edit: Some IDEs have implemented UI for handling git, so if you find yourself very not fond of command line this might be the way to go. Although you still need to understand basic concepts.
10
u/Blando-Cartesian Apr 16 '21 edited Apr 16 '21
This. Feel free to use whatever GUI tools for you like for it and start using it as a backup at least. Github has good setup instructions and after that the only git commands you need to get started are commit and push. Tutorials always make it seem massively complex by throwing dozens of concepts to you from the start. It is complex, but you need to know very little of it for it to be useful.
2
14
2
u/currentXchange Apr 17 '21
I think that it's good to mention you don't even have to write code if you use Atom, prob others too. Just understand the concepts.
1
637
Apr 16 '21
or: create many files in a folder ranging from "old", "new", "test", "idea", "delete", "asdf", etc. and a thumb drive with one called "doomsday". surely this is industry standard.
269
u/rmgxy Apr 16 '21
The industry standard is to keep adding "_new" at the end of the file and counting how many you have to figure out the newest new.
158
u/OvulatingScrotum Apr 16 '21
“Final_final_revision_submission”
94
Apr 16 '21
V2
40
u/duquesne419 Apr 16 '21
final.v4.dontedit.noreally.v2
I swear, marking a file 'don't edit, working' is like putting it on my list of things to fuck up next.
19
23
2
34
u/sad_panda91 Apr 16 '21
_new (1) (1)
11
u/fr33d0ml0v3r Apr 16 '21
wait, this is not the correct way?? that explain why I cant remember what the hell the names means after a couple of weeks.
→ More replies (3)4
u/corruptedOverdrive Apr 17 '21
Or if you really want to piss off your co-workers just do something like this:
string result = Path.GetRandomFileName(); Console.WriteLine("Random file name is " + result); }
We had a few devs who would do this with personal projects to stay "under the radar" ifyouknowehstimean
53
u/SammyWammy007 Apr 16 '21
And when you iron out the kinks rename it to _FINAL
22
20
11
u/Bukszpryt Apr 16 '21
i used names like final final so many times, that now i just add a date at the end of the file name.
4
7
3
u/TheSuperWig Apr 17 '21
_FINAL Copy
But it's been modified and is actually the latest.
→ More replies (1)2
u/spaghetee_monster Apr 17 '21
This happens so many times so now I just enter the current date at the end of the file name.. so you know to pick the latest one.
2
24
u/alwayswatchyoursix Apr 17 '21
Just use my dad's system for his presentations.
Put the date you created the file at the end of the file name.
Every time you update the file, save it as a new copy but don't change the date.
Then put version number (3, 4, so on) after the date.
Then mention that you've made changes (updated, new, fixed, etc.) after the version number.
Occasionally forget to make any changes to the name so you end up with MS Office just adding a new number to the end.
Make sure you keep all of them in the same folder.
Each time you want to update the latest version, spend half an hour looking for the correct file.
Call me and have me come over to look through the files, but refuse to change the filename when I do find the right one and suggest fixing it.
And that's how you end up with stuff like "Foundation Quarterly Presentation for Austin Chapter Q3 11212016 v8 updated (7)" still being used in April of 2021.
2
15
7
11
u/PoopEndeavor Apr 16 '21
You are the first redditor I can ever recall seeing with what could actually be a real photo of you. A whole-ass, real-ass, human-ass face. Feels weird. But also like you should get some kind of Medal of Bravery
10
5
u/Bukszpryt Apr 16 '21
yor post reminded me of many files i've made or used at work. new, newest, last, final, last final, redacted etc.
5
Apr 16 '21
"redacted" has to be the funniest example
2
u/Bukszpryt Apr 17 '21
tbh it's just a loose translation. english is not my default language, so i don't use it in my file names.
→ More replies (2)7
3
u/Mike312 Apr 17 '21
We have a complicated system that appends .new.bak and .old.bak to files, and the file that literally keeps our network of customers online, and has been for the last 5 years, is marked as .dev
3
1
1
u/mutantkwds Apr 17 '21
My concept of organization when I first started learning was creating a folder with the name of the language and naming the files something generic like "exerciseDDMMYY". It was great at the beginning but after a few months I had to open like 10 of them to before finding what I needed.
146
u/madmoneymcgee Apr 16 '21
I have a weird path where I started working in a software office before becoming a developer.
Git was how I learned the command line. It was really some of the first dev-specific stuff I did,
I was kind of shocked to see it’s not something an actual CS grad might come out of college knowing.
38
u/redderper Apr 16 '21
Do CS students not use git??
55
Apr 16 '21
It's not taught in class, but some may use it for personal projects if they still have time for that kind of thing.
19
14
3
u/LoloTheWarPigeon Apr 17 '21
Not true - I had a course that had sections specifically catered to learning Git, and the course is required to graduate.
→ More replies (2)32
Apr 17 '21
They don’t teach it. The whole field of CS in college is a fucking farce — they are all up their own asses about how it isn’t meant to be career prep, but that’s what 95% of people are there for, and there really isn’t another option that employers will accept as proof of education. They spend an insane amount of time on linked lists, manual memory management, and all sorts of things that are nice to know, but they drill so deeply into those things that things like version control don’t even enter the picture. You can very easily get a comp sci degree and be two years out from being able to take on a junior dev role without constant supervision, which is inexcusable. If someone is giving you tens of thousands of dollars and 4 years of their life because they want to be prepared for a career, that’s just not an acceptable outcome. They can point their noses in the air all they want about how that’s not what a university is, but that’s just grossly irresponsible and ignores the facts of the situation. College is a fucking scam.
7
u/pineapple_catapult Apr 17 '21
There really needs to be two separate tracks: software dev, and computational analytics with a more heavy math focus. My college did this, the latter required a few extra courses. The software dev track was "standard". They did have us use Git in some group projects, which was great to have coming out into the workforce.
11
u/Xvash2 Apr 17 '21
Yep can confirm, my CS degree was far more research-oriented than practicality-oriented. Thanks to one senior tenured professor, we had a required class about his own specially-forked version of Haskell and why it and Haskell and functional programming were superior for research than object-oriented languages.
4
→ More replies (3)3
Apr 17 '21
I think this is endemic to a lot of STEM professions. They’re taught by researchers so the curriculum ends up looking like prep for research and not prep for an industry career.
My background is mechanical engineering and it’s very much the same. You’ll do things like finite element equations by hand, but in 4 years nobody will mention the common standards that devices are designed to.
2
u/aiiye Apr 17 '21
As a dude currently two terms from finishing a Software Dev degree, I’m glad I’m learning actual engineering work from my coworkers to combine schoolwork into practical things.
→ More replies (3)2
u/LoloTheWarPigeon Apr 17 '21
Git is taught in a required course at my university. There is no point at generalization here.
11
u/svada123 Apr 16 '21
Currently learning linux commands, git/github, unit testing, and design patterns in a software construction course at UCR. I'm in year 3 but this is the first upper div course i'm required to take.
→ More replies (3)7
Apr 17 '21
10 years ago, I learned literally 0 of those during my 4 years at college
4
u/PC__LOAD__LETTER Apr 17 '21
10 years ago is a very long time given the age of the profession though.
→ More replies (4)→ More replies (9)2
u/redfade97 Apr 17 '21
I’ve been taught how to use git at my school. I turn my assignments through git.
2
u/phpdevster Apr 17 '21
Git is so fundamental I don't even ask about it when interviewing candidates. I guess I probably should explicitly ask for git knowledge, but I just assume you know git the way I assume you know how to send an email.
4
u/icandoMATHs Apr 16 '21
At least it's trivial to learn
55
u/HolaGuacamola Apr 16 '21
If you've ever taught many people git, you'll definitely realize it is not trivial.
20
u/cheunste Apr 16 '21
I attempted to introduce some of the other (non software) engineers to git. Not even teach. Introduce. Needless to say, the only thing I've learned from giving that presentation is that if they really want to learn git, I'm going to have to get a whip and literally force them to use it or I go crazy.
15
u/brisk_ Apr 16 '21
The lead dev at my first job out of school basically didn't even really try to teach me git, he just left me to do my own thing in my dev environment (Cloud9) and then he'd go into my account and push everything himself.
I finally learned it at my second job; lead dev here has an entire knowledge base that is designed around workflows rather than learning specific tools. So he taught me how I would use it specifically for each issue/ticket/project, then after I'd grown comfortable, he added a bunch of information on the base of what I already knew. He's repeated this style for a lot of what I've learned so far and it's made my ability to adapt to new things so much easier.
11
u/PM_ME_YOUR_DOOTFILES Apr 16 '21
Especially if it's their first time using the CLI. It's a bit of a rough introduction.
4
u/mackthehobbit Apr 16 '21
When there are so many good GUI tools available, I’m not sure why you’d teach it with the cli only. I say this as a CLI-only user (well, plus vscode’s commit dialog)
→ More replies (3)3
4
u/J0035 Apr 16 '21
Also when considering that most of us don't even use the whole potential of git. Becoming a power user is for sure not trivial :)
→ More replies (1)4
u/madmoneymcgee Apr 17 '21
Git is weird in that it’s easier to use but once I mess something up fixing/debugging is way harder that other things.
1
u/MakerTech Apr 17 '21
At my bachelor program in Software Technology (Denmark, DTU), version control is taught on the first semester.
One the second semester there was also an obligatory course on version control, unit testing, clean code and design patterns.
And all of this is then expected to be used in all other courses afterwards.However, I know that some of the other universities doesn't teach all of this yet here either. Or at least the graduates don't all know it when they apply for a job afterwards.
→ More replies (1)1
38
u/Lombadd Apr 16 '21
I've been trying to get to grips with git + github but like you said its v intimidating for me as a newbie. I also find that I keep running into problems, like for example i can push to master but not to main, and it takes a lot of googling to even figure out the beginning of where I should start to understand the problem. Is there like a quick, easy and up to date intro to git that anyone knows of that could help me with git?
30
Apr 16 '21
Master has been deprecated for new projects. If you have an older project the “main” branch may be called “master”. But new projects will be started with “main” as the primary branch
→ More replies (6)9
u/Lombadd Apr 16 '21
Thank you, but my problem is actually that I can't push to main at all. I can push to (what I think is) a new branch called "master," but trying to push to main brings up a v generic error message. This might not be the place to troubleshoot my git problems so I don't want to take up too much space with it, but I appreciate the comment
15
Apr 16 '21
Did you change the default branch to main?
In the command line,
git config --global init.defaultBranch mainI'm just starting to learn programming and Git, I'm taking the Odin Project. They mention this in their "Setting Up Git" lesson.
4
4
u/duquesne419 Apr 16 '21
/r/git has always been helpful for me, if you don't get your answer here try over there.
→ More replies (1)3
Apr 16 '21
Yeah sounds good. If you input git status it will tell you your current branch to see if it matches what you think it is
12
u/imratherconfused Apr 16 '21
Heyoooo. 90% of git users use like max 20% of the options available. If you can rebase, merge, cherry pick, pull, push and fetch + commit then you're at the same level most of us are :)
15
u/phuntism Apr 17 '21
Whoa, rebase and cherry? You must be some kind of git admin.
3
Apr 17 '21
Rebase is bit advanced but cherry is helpful to use daily, it's to copy a commit from one branch to another.
3
u/RoguePlanet1 Apr 17 '21
YouTube has a series called The Coding Train, with a very goofy but fun and smart instructor. He does a lesson on Git using words instead of code, might be a good place to start, makes the process less intimidating.
That said, I learned github in bootcamp and it still scares me! The command line stuff is confusing, but you can also default to drag/drop when desperate.
3
u/CptQueefles Apr 16 '21
For me, starting with a UI system like Source tree helped me really visualize and understand how it all works. I would suggest trying that out if you've struggled with command line!
1
u/Lombadd Apr 17 '21
Just wanted to say thank you to everyone on this thread!! Didn't expect so many responses, I really appreciate it :)
1
u/gmorf33 Apr 17 '21
VS Code's github integration is what got me finally using it regularly. I just did my first use of branches this week and it was awesome. Couldn't be simpler with VS Code. One of our vendors moved to a new API platform which changed a lot of stuff w/ their endpoints, oauth2, etc. I was able to make a new branch to work on all the new changes without breaking anything in the existing main branch. When i was all done and tested, it was super simple to merge the new branch into main and like magic it was done.
46
u/Okmanl Apr 16 '21
Another thing I wish I was told early on was to learn test driven development or at the very least how to write unit test.
I wasted countless hours on larger sized projects because I didn't write a single unit test. I was too afraid to refactor code because I thought it would break something. Every time I added new code and it introduced a bug I had to put logging statements everywhere and had to manually test every single feature to make sure everything worked properly.
There was a point where I was thinking to myself "damn, I don't know how other people are able to write large projects, maybe programming isn't for me after all."
Turns out it was because I wasn't writing unit tests, once I discovered it it made a world of a difference in being productive. Strangely enough it's something that's not taught at all in school or even in tutorials.
11
u/purplebrown_updown Apr 16 '21
Writing tests is a must for almost any code. I haven’t gotten in the habit of doing it for small scripts but I probably should.
5
u/EngineeredToLift Apr 17 '21
This is exactly what I need to start doing. Was modifying my code and running the whole program every damn time. Where is a good resource to learn this?
3
u/Yaaruda Apr 17 '21
But isn't writing unit tests time consuming in itself? It can be a hell of a task in setting up an independent test environment. Of course I understand the merits of that, especially in larger projects, but for relatively smaller ones where functionality keeps changing, isn't this the worst way to invest in developer time?
Imo, the unit test approach only depends on the type of codebase you're working on. If you're already dealing with production ready code, it could save you quite a bit of time. Otherwise I think the traditional approach makes more sense if you're working on a nascent project / module
2
Apr 17 '21
I am at the tail end of a full stack JS course on treehouse and I can say writing back end work with TDD made life so much easier. I haven't quite gotten a grasp on testing front end stuff like react and I really felt how much harder it was to write my front end without TDD.
3
77
u/paradigmx Apr 16 '21
Do you want to program? You need to learn git. Full stop. You wrote hello world for the first time? Cool! Initialize a repository, add the file, and make a commit. Bake that shit into your head alongside learning how to program. It doesn't matter what languages you use, what editors or ide you use, or what your workflow will look like, git will be a part of it. Windows, Mac, Linux, you'll use git. Open source, closed source, you'll use git. Dedicate 20 minutes to installing it and learning a few commands. Dedicate 20 seconds to making a commit regularly while you learn. You will always use it.
If you don't know git, stop what you're working on and learn it.
20
u/Srr013 Apr 16 '21
I am a hiring manager for a development shop. Git is a key skill. If you can’t talk about core git concepts coherently then I can’t trust that you know how to do development in a collaborative or corporate environment.
15
u/orbit222 Apr 16 '21 edited Apr 16 '21
I get what you mean, but I have a different personal experience. I've been a professional software developer for coming on 11 years now, and my company has always used subversion. We've worked with some major, major clients, and always been perfectly fine. We're now transitioning to git because, as you said, git is a key skill. But I absolutely know how to do development in a collaborative and corporate environment despite not using git until this very year.
14
u/jerallen Apr 16 '21
I think you could replace "git" with "version control software". While git is popular its not the only way. Preferring tools and languages blindly because of their popularity is a problem.
→ More replies (2)2
u/AgentTin Apr 16 '21
Yes. You're correct. And if this was advise for people learning to program 11 years ago, subversion would absolutely be mentioned as an option. If you're getting started programming today, the only reason to learn subversion is if you're working with old codebases. For any project started in the last few years, Git has been the obvious choice, and now it has momentum. Never used subversion, don't know if it's as good or better, my office uses Git.
0
5
4
3
10
u/thunder_jaxx Apr 17 '21 edited Apr 17 '21
The Idiot's Guide to branching Code (I Follow it. It assumes u understand the concept of branching):
Master is holy after the first stable working version of code. Start Branching out once something initially works.
Branch often. Commit small. Squash Large.
Github is your friend, make the use of pull-requests/branching when inspired to make changes to working source code after your third joint.
A good commit message gives you more insight on code than a comment ever will.
Branch comparisons are the richest places for bug discovery. If you really wanna know how you fucked up.
Don't use git-operations you don't know. Sometimes being fancy pants and rebasing things can fuck things up for other people if repositories are not well monitored.
Follow the naming nomenclature for important workflow-related branches makes the life of the full team easier.
How you merge Matters. b->m and m->b is not the same.
Don't be the dick on the team who commits that 1GB file to remote fucks over the entire system's workflow. In ever the case of committing large size data. Just Don't.
When it doubt. Branch it out.
Branching makes us together work better alone.
→ More replies (1)
9
u/ImNotBlueBanana Apr 16 '21
I once had to learn to use it in a game jam and spent 6 days on git and one on the actual game
8
u/TazDingoYes Apr 16 '21
It took me 5 attempts over I think 6 years total to learn it. I had like the most socially inept software engineers attempting to explain it to me each time and I HATED it SO MUCH. I had this visceral reaction anytime brought up GIT and wanting to teach it to me because of them. They never started with the terminal, just download GitKraken, here's our project, anfkdnsknsknjkd".
Bit the bullet and taught myself very recently and I have changed my mind, I really like it now. There were teething issues, but learning via the terminal was so much easier (and honestly right now I still prefer it over a gui).
So yeah, I guess persist. Maybe 6 time's the charm.
2
Apr 16 '21
So where did you learn... any particular video/channel you recommend?
8
u/lorengphd Apr 16 '21
LPT for your feature branches: git commit - -amend
To make a change to your previous commit. You don’t need to have 4 commits all saying “make adjustment to last commit”
Edit: formatting
1
u/AlotOfReading Apr 17 '21
Be careful amending commits. If you amend something and you later want to unroll that amendment for some reason, you have to go reflog diving to get it back. Better hope the original hasn't been garbage collected either. It's much safer to make the amendments their own commits and squash them together with a rebase once you have everything fully working.
→ More replies (1)
6
u/fathed Apr 16 '21
While git is great for code, it’s still not great for large binary files, like psds.
Learn the concepts of revision control, it doesn’t have to be just source code, or git.
But you should still learn git...
4
u/Informal_Swordfish89 Apr 17 '21
I'm actually pissed at the number of CS grads not knowing how to effectively use git.
1
u/BattleNub89 Apr 16 '21
I'm getting back into coding again, and this has been my first step. I have an old project, and the only thing I'm doing with it is learning how to make safe changes to it, test it, then commit when I'm actually ready. Skewered a Discord bot I made by not having version control.
1
u/Szahu Apr 17 '21
I'd suggest creating a new branch everytime you need to add issue, it's really simpler than it sounds. Just do git branch name-of-the-branch and then git checkout name-of-the-branch. Now you are working on the separate local branch (you can set it up to make it remote too, just use git push and the prompt will give you the correct more complicated command). You can then develope your feature then check out to master and merge them.
1
u/bsjf120 Apr 17 '21
Any good resource suggestions to learn GIt? Specific websites or YouTube videos?
1
1
u/UnsungSaviour Apr 17 '21
I’ve heard about this. I’m completely ignorant of it but it’s some cloud that stores code?
I believe you can use other alternatives than git but is git generally the best?
2
u/Szahu Apr 17 '21
It is much more then cloud to store code. The idea is that you upload code in small quantities which are called 'commits' so let's sey you added your feature you commit and push your new feature to GitHub but then all of a sudden your code doesn't work and you do not know what to delete to get it back to workin state. Then you can go to GitHub and get a version of your code from before to commited feature.
Another feature of git is you can work on many different versions of project at the same time without the need of copying files or any buck-ups.
Regarding alternatives, there are some but I have no experience and knowledge about them. Git and GitHub seem to be the most popular version control tool.
→ More replies (1)
3
u/Geedis2020 Apr 16 '21
So your saying after it’s not standard after you screw up your code to just hit undo over and over until it gets back to when it worked?
2
8
u/noclue2k Apr 16 '21 edited Apr 16 '21
Serious question: who pays for it? I mean, there must be hundreds of millions of fledgling programmers in the world, and if they all store all their versions of all the programs they write, that would be an unbelievable amount of data, costing a ton of money to host. And if you are just using commands rather than browsing to the website, you don't even see any banner ads, which most people have learned to filter out of their awareness anyway. So how is this funded?
EDIT: In a stroke of genius, I decided to Google it. Github is owned by Microsoft, and while small projects are free, they do charge for services that corporations are likely to require. Mystery solved.
16
u/morsmordr Apr 16 '21
it's also important to understand there's a distinction between git and GitHub.
git is a free tool anyone can host and use. you install it locally, and it saves a record of your changes locally.
GitHub is not a tool, it's a platform used to share code in repositories. That's the bit you spoke to in terms of how they're funded. There are other alternatives out there, that are plenty reputable and recognized, Github is just the most popular.
11
u/AgentTin Apr 16 '21
I've heard it said that the difference between git and github is the same as between porn and pornhub.
4
u/Kingizzardthelizard Apr 17 '21
Lol. Github doesn't host git like pornhub hosts porn. Github hosts projects/configs/code using a tool named git
→ More replies (2)1
Apr 17 '21
Github is not git. Fuck github, they got bought by microsoft, don't use it, use bitbucket or gitlab.
Git is the opensource tool that provides the actual functionality.
1
u/mikewazaoski6969 Apr 16 '21
I feel very confused there are so many resources to learn git idk where to start. Is there any course/website/book which teaches all about git that we need to know as beginners and covers the commands (idk if this is the right terminology) that is used in corporate world?
1
u/Szahu Apr 17 '21
I can only tell you about what I use, which I have no idea if is correct or not, but it gets the job done
4
u/AgentTin Apr 17 '21
Someone near the top mentioned https://learngitbranching.js.org/
Not an endorsement from me, just passing it on.
EDIT: u/TravestyTravis
1
u/oFabo Apr 17 '21
There is also https://ooloo.io/project/github-flow , which is a bit more advanced.
2
2
u/Metawoo Apr 16 '21
I'm suddenly thanking the universe that Git and Bash were the first things I learned in my web dev class.
2
Apr 16 '21
I wish colleges would put some kind of emphasis into using IDE's, debuggers, and Git, I understand avoiding it for the first couple of years, but it's crucial knowledge.
4
u/istarian Apr 17 '21
Some schools do, but realistically computer science != software engineering and college is not about vocational training.
→ More replies (1)
2
Apr 16 '21
It takes like 30 minutes to learn git, idk why this needs to be said (I’m a beginner and still know how to use git/GitHub)
2
u/dipsy01 Apr 16 '21
GitHub is incredible. Definitely intimidating for noobs but it’s seriously not bad.
GitHub also made private repo’s free within the last year or two 😎
1
Apr 17 '21
Please don't use github. They got bought by microsoft. If you care about opensource, move to gitlab or bitbucket.
2
u/MrPresidentNZ Apr 16 '21
Why is git so intimidating? If you are learning and just doing solo projects, there's only a few commands you need to know for it to be useful. I get there's a lot more to it than committing, pushing and making branches but for people starting out those are all you really need for the time being, and its extremely simple to learn the basics.
2
u/ronsap123 Apr 16 '21
Also if you ever hope to find a job in the industry, you need to be a git bender. This will earn you so many points. It's priceless.
2
u/DahPhuzz Apr 17 '21
I just don’t understand how git rebase works and never use it. Other than that I’m cool.
2
Apr 17 '21
There's a lot of commands I don't know and I've been in the industry for 3 years. As long as you can create and switch branches/commit/fetch/merge/push you're good and everything else you can kind of look up as you go.
(Also never used rebase 😂)
2
u/DahPhuzz Apr 17 '21
How did remote teams ever developed software before git is beyond me
2
Apr 17 '21
I mean I'm sure remote teams are way more common these days with the various internet collaboration tools, but version control systems go back a long time too. SCCS was made in the 70s!
https://initialcommit.com/blog/Technical-Guide-VCS-Internals
2
u/captain_dudeman Apr 17 '21
For those of you in college: do not leave college without understanding git. A junior software developer needs to know how to version control a project. Nothing crazy, just pushes, pulls, commits, and merges.
2
u/pixel8dmess Apr 17 '21
Check out this free tutorial on Udemy to learn Git: https://www.udemy.com/course/git-expert-4-hours/
2
3
u/nando1969 Apr 16 '21
I like to think of Git as Car Insurance, it's a pre-requisite.
→ More replies (4)
1
u/masterprocrast99 Apr 16 '21
Just installed git but I don't get something:
Me and my team need to work on some project, and I wanted to use some task management software. One of team members told me that we can arrange tasks with just git by making folders and committing changes. Can someone explain how to use git for this? Thanks in advance
3
Apr 16 '21
I'm just guessing about what your team member meant, but you can certainly make separate branches for each task. Once the task is complete and tested, you can merge it back into the master project.
2
2
u/vicks9880 Apr 16 '21 edited Apr 16 '21
Do you mean tasks like who is assigned what and what status that task is in? Its called "project board" is available on github is free automated kanban
→ More replies (1)
1
1
u/Chompskyy Apr 16 '21
I imagine there are all sorts of reasons for when/why but...
What are some of you guys' preference for when to make a new commit?
Every programming session? Every time you implement a new feature? Every time you feel like you've personally made progress? When you want to share the most recent iteration of your project?
All of these?
When are some reasons you would fork into a new branch?
Only for projects and working with teams? When building a new feature(s)?
Are there other reasons for doing things that I'm missing? I imagine it's a combination of all of these things and you can be creative in how you use the technology, I guess my question is...
What are some other reasons you can think of to use these things?
2
Apr 17 '21
I usually commit whenever I've made a step forward.
I know that's super vague, but like if I've made the source better in some way and I feel like I need to take a break, I commit. Some examples:
if the build is broken, I've made it worse, and I usually dont commit
if I change some doc comments, commit
write a new function or functions, commit
That is to say, it's more based on where I'm at logically rather than a time thing. I think of it like a "serious save". Committing once for each feature is probably not frequent enough though.
Why make a branch? I usually do one branch per feature/project. That way I can easily scrap it I'd i feel I went in the wrong direction. It also means I can work on multiple projects at once. (And as you mentioned it helps with teams). One nit: I don't think I've ever heard someone say they "fork" a branch. I usually hear it when someone says they "forked" a repo.
All in all, the reasons for using version control are simple:
ability to revert to previous versions easily (like going back in time)
enhanced collaboration
in the case of Git and other DVCS, your code is distributed among the team, so it's unlikely you will lose it from a disk failure or some such.
→ More replies (2)
1
u/wh33t Apr 16 '21
I have a question, when you have like 10 people on merging code back into the main branch doesn't chaos always immediately ensue?
1
1
u/purplebrown_updown Apr 16 '21
I’ve been using it for years and still have no clue how to revert to an old version. I kinda feel like most people are in the same boat. Which begs the question, is it really that good? The commands seem very unintuitive. Anyone used a GUI version. Is that easier?
2
Apr 17 '21
GUI I'd easier, definitely try that, but I prefer command line in the end bc the interface is unlikely to change and it's faster.
Doing the more complicated things in git is usually just a search away: https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit
Sure it could be more intuitive, but I don't think reverting your repo should be too easy either :)
1
1
u/sunole123 Apr 17 '21
How do you fix conflict. Every damn push pull the code is messed up. Say I accepted 10 changes. And then merge failed. What do I do?
1
1
1
1
Apr 17 '21
They also now have a desktop version that makes it sooooo much easier without having to fuck with command line
1
u/sandiego34 Apr 17 '21
what if I use it via user interface. the IDEs support this. to be honest I do not understand the commands. I have tried but there was a bunch of complicated things. so until I learn can I use it via UI, like using buttons etc. there is simple ways. does that make me looser
0
1
u/DahPhuzz Apr 17 '21
How did remote teams ever developed software before git is beyond me
1
u/gnuwinxp Apr 18 '21
there was/is Subversion, CVS, and SCCS before git, however they were/are worse
1
u/bribeav Apr 17 '21
We barely touched on source control in college, but, to me anyways, it’s by far the most important thing a developer should be comfortable with.
1
u/Xpgamer7 Apr 17 '21
This is kinda late and might get buried. But this timing is too coincidental. Some devs just released a freeware game to teach git just a few days ago and I saw it on Rock paper shotgun. Here's the link to their thing: https://ohmygit.org/
1
u/PC__LOAD__LETTER Apr 17 '21
TL;DR: Know how game checkpoints and saves are awesome? Git lets you do that for code. And there aren’t limits on the number of saves and checkpoints you can make.
1
1
u/jluizsouzadev Apr 17 '21
Absolutely the first thing a dev must learn for sure is git. It's gonna ease too much the learning journey because a dev's gonna share it's own code and to get access to other devs' code for analyzing and learning from it. Indeed! That's what I've always told about for anyone asks me about some reason for learning git.
1
1
u/UpbeatCheetah7710 Apr 17 '21
Man, as someone who just created an app crashing mystery bug that doesn’t even flag an error, I appreciate this and am gonna look into it so next time I can just roll back my code :|
1
u/AStrangeStranger Apr 17 '21
if you are on Windows then there is also the option of TortoiseGit which integrates into the Windows Explorer File manager - I find it much better at reviewing changes and selecting what I want to commit than IDE integrations/Command line
1
u/Morpheyz Apr 17 '21
What keeps me from using git sometimes is that I often work all lover the place. I don't think I'm the only one, but I feel like I haven't discovered the right workflow yet for how to deal with this.
I understand the basics of branching and merging, why merge conflicts happen, etc. What's always in my way is that people say that branching allows you to try out ideas quickly and then possibly throw them away if you're not happy with them. I often find myself being in a feature branch, then fixing a little typo or refactoring a variable, or other things that are very minor improvements. If I don't decide to merge that feature branch eventually, those changes are lost on the main branch. I know that technically, for things that don't concern the feature branch, you shouldn't change any of those things, but I just can't bring myself to switch branches every single time I make minor adjustments to the code. Is this just a matter of discipline?
Btw, I don't use git in a professional setting, only for my personal projects.
0
1
1
1
1
u/joelwitherspoon Apr 17 '21
I HIGHLY recommend Ry's Git Tutorial. Once done, you'll know way more about Git that you did when you were born.
2
u/stone_cold_kerbal Apr 19 '21
Ry's Git Tutorial
https://github.com/syn-bit/ry-s-git-tutorial for book and code examples
1
u/Kakss_ Apr 17 '21
Implying I ever get far enough in the project that it's worth investing in version control.
Though one thing always makes me curious. How does merging branches work? Especially considering that afaik git also lets people work on different features of same project simultaneously, but then how does it know how to merge a couple of different branches?
0
1
u/captain_obvious_here Apr 17 '21
Serious question: Are there still people in development who don't use a versioning system?
0
1
u/gingerBeardMan750 Apr 17 '21
Totally agree. Having a basic understanding of git/github should be a minimum requirement for a web/software development job.
I didn't know much about git/github at my last job, and it really hindered my success there.
At my new job, im providing the more experienced devs training on how to use it effectively.
1
u/firestepper Apr 17 '21
Git is important to learn... personally i think it's important to learn how to use git with others
1
u/IvAntiVirus Apr 17 '21
Totally agree. If you wan't to work as a application engineer/developer you just have to know Git. Almost every company is using it besides a few who still stick to Apache Subversion.
1
u/alycrafticus Apr 17 '21
Many IDE's have Version Control built in, one platform of which is Git. Its super easy to set up, its reliable, and will save you much heartache I promise. I have been learning java for like a month and fisrt thing I set up was a git to keep a backup and branch for dev
1
u/coder155ml Apr 17 '21
I wish I learned git much earlier in college, would have saved me hours of despair
1
u/CaliforniaDreamer246 Apr 17 '21
This post seems to be personally written to me, I’ve been putting off learning git for the last couple of weeks
1
1
u/qpazza Apr 17 '21
I honestly thought learning git was like step 1 of learning to become a developer.
1
u/mrmopper0 Apr 17 '21
My company is switching from subversion to git. I've used it for personal projects but never really had a need for extensive branching. Honestly the worst thing is people who have used it a lot insist projects go from 0 to 100 overnight and get pissy about projects not being fully integrated two weeks after the all hands saying we are making the switch!
therapy
1
u/ferlonsaeid Apr 18 '21
I'd recommend learning command line anyway. As a dev you'll need to get comfortable with it anyway.
I had a "senior" dev who had no clue how to use git on command line (or command line for that matter). Didn't take long for him to be dropped.
69
u/[deleted] Apr 16 '21
This may come across as pedantic, but just want to add that what you said above could also be done by using other version management tool (svn, cvs, etc.). But I do agree that if someone never use version management tool before, Git is probably the way to go being the most currently popular, and some of its features that make it more desirable.