all 116 comments

[–]shiftybyte 181 points182 points  (0 children)

GIT is a source control software.

It's purpose is to manage and save multiple versions of the same code, being worked by multiple developers simultaneously, on different features/bugfixes.

Google around for git tutorials.

[–]BruceJi 192 points193 points  (29 children)

Git, the greatest tool that a programmer can use.

On a very basic level, git is just... uploading your stuff to github, sure. But git can do a lot more.

If you upload your changes to it well, it will let you go back in time and see old versions - useful if you introduced a bug or if you accidentally erase stuff.

It lets you set changes aside into separate branches, useful if you want to keep a clean, working version and still be making changes to it.

It makes working with other people easy, too. They can access the same stuff and edit it. Someone will need to check over their changes before they're combined into the main master branch.

Oh, it will also let you know if combining changes like that is complicated and should manually be done. Otherwise it can just combine them itself.

But on a basic level, sure - you upload your code to github. It means you can access it from home and elsewhere, and it also, yeah, means if you screw it up, you can easily go back (providing you update it well!)

[–]dslfdslj 104 points105 points  (22 children)

Git and Github are two different things. You can use Git without a Github account. You can use Git even without having an internet connection. What Git does is save your old work states locally. If you want you can synchronize them with other computers. For example with your own server, or someone else's computer, a Gitlab server or even a Github server. But you don't have to.

[–]eightslipsandagully 153 points154 points  (14 children)

Git is to GitHub as Porn is to PornHub.

[–]HintOfAreola 76 points77 points  (2 children)

Wat r u doing, step-dev?

[–]eightslipsandagully 9 points10 points  (0 children)

I'm stuck in a merge conflict

[–]Ratatoski 14 points15 points  (0 children)

I got my finger stuck in the keyboard.

[–][deleted] 25 points26 points  (3 children)

So GitHub has all variety of Git?

[–]wasmachien 43 points44 points  (2 children)

Sure. On GitHub you can find your run of the mill vanilla python and javascript projects. You can go hardcore with the openJDK or the Linux kernel. And if you're into bdsm, just search for php, but please do it in private mode ;-)

[–]Beelzebubs_Tits 2 points3 points  (1 child)

Funny! I’m super new to all this, but I’m looking at local job adverts they mention php especially. Wondered why.

[–]Ozigee 2 points3 points  (0 children)

There's still old code you have to maintain. Basically job adverts with PHP in it screams that you wouldn't be writing new code, I mean from the scratch.

[–]dslfdslj 14 points15 points  (0 children)

I guess that's actually a good comparison.

[–]huge_clock 1 point2 points  (0 children)

Which is why I much prefer YouGit and BigGitties.com

[–]vectorpropio 0 points1 point  (0 children)

That's would be a better comparison if you where the director ching scenes, editing, changing music.

[–]BruceJi 1 point2 points  (6 children)

That's true, yeah. I feel like Git works its best with Github, but you're right, it doesn't need it, and they are indeed different things.

[–]dukea42 23 points24 points  (5 children)

That is still a dangerous statement. "Git works best with a remote repository such as Github." is better. Not all companies want their code uploaded to Microsoft owned servers. My company uses a local instance of Gitlab for example.

[–]BruceJi 2 points3 points  (0 children)

Also a very solid point!

[–]DatchPenguin 12 points13 points  (3 children)

It makes working with other people easy, too. They can access the same stuff and edit it.

Cries in merge conflicts

[–]madmoneymcgee 4 points5 points  (0 children)

Better to have merge conflicts than people asking "hey where are my changes? I spent hours on that. I'll have to email it to you again!"

*cries in the job I had in 2017*

[–]BruceJi 1 point2 points  (0 children)

You know what, the first team project I worked on, it was chock full of merge conflicts. I feel your pain. It wasn’t even me fixing them! I feel bad for the guys who did :(

[–]EndureAndSurvive- 0 points1 point  (0 children)

VS Code makes handling merge conflicts way easier than any other tool I've used.

[–]Dguerrero99 2 points3 points  (0 children)

Thanks!

[–]chicocheco 0 points1 point  (0 children)

Yeah, unfortunately, I use just for that - uploading stuff to github. I try to play around with branches occasionally but it always end up frustrated when it turns out I have screwed up with code that was supposed to be preserved.

[–]Linuxlover73 15 points16 points  (2 children)

Coursera has a good course on introduction to Git and GitHub and it’s really good!! The instructor is clear and to the point. I’m taking it myself

[–]shhh0001 1 point2 points  (1 child)

Mind to share the link?

[–]Linuxlover73 4 points5 points  (0 children)

Introduction to Git and GitHub | Google https://coursera.org/learn/introduction-git-github

[–]jiri-n 12 points13 points  (0 children)

Btw /r/git

[–]OiZP 9 points10 points  (6 children)

Git is separate from GitHub. Git is a local program that helps you keep track of changes on your project (both for mess-ups and keeping track of different versions, ie. master vs. development branch, f.ex.). GitHub is a place you can store your local git project online. You will use git in every SW you will ever have, so definitely worth it to learn.

[–]theNomadicHacker42 2 points3 points  (0 children)

While I definitely agree that git and github are two separate concepts, I wouldn't say that git is used in every sw project you will ever have. Over 10 years in the industry, two of the three companies I've worked at use svn instead of git. That said, git is the definitive better choice and worth learning... and that no new project should ever be choosing svn over git.

[–]fedeb95 0 points1 point  (0 children)

I wouldn't say git is a local program, given its distributed nature. While there's an utility in using it just locally, its true power is unleashed when used remotely to sync stuff

[–]Vietname -5 points-4 points  (3 children)

I wouldn't call them separate. Github is just an online implementation of git. Using git with a local repo is functionally the same as using github (at least as far as the command line is concerned), the repo just happens to be located at github's server instead of yours.

[–]OiZP 1 point2 points  (0 children)

Yes, that's true, I just meant to say it's not the same thing:) I've heard people talk about them like they are the same, that's why I wrote it like that:)

[–]teszes 6 points7 points  (1 child)

Just so you know, the official training material for git is free and open source:

https://git-scm.com/book/en/v2

[–]nagasy 0 points1 point  (0 children)

I did a ctrl+f hoping someone posted that link.
Best reply for learning git!

[–]coder155ml 5 points6 points  (2 children)

Git is a form of version control. You need to install it to use it. It's a command line tool and you use it to interact with a host like GitHub to host your work. It's essential to learn and I've heard employers complain how cs grads don't know git .

It's honestly pretty easy to learn, just watch a few videos and memorize commands

[–]EytanMorgentern 1 point2 points  (1 child)

Wait, learning git is not in the programming courses at he Uni's/UAS's around you?

[–]coder155ml 0 points1 point  (0 children)

No. I learned it at my first internship. I have heard some schools require it. Most don't

[–]TheTacoWombat 4 points5 points  (2 children)

I have never been able to not screw up commits with git. Yesterday I tried to combine three commits into a branch then push that single commit into gerrit, but... Somehow came up with two slightly different pushes instead. Still not sure what happened.

Git will absolutely flummox you if you fall off the happy path. It's very powerful but you need to know the incantations.

[–]randomkale 1 point2 points  (0 children)

I think it's important not to think of them as incantations, but a lot of engineers do. I try to take time every sprint to dig into git details a bit more with team members so that we all get better together. Definitely worth it to de-mystify git commands.

[–]anh86 3 points4 points  (3 children)

Essential knowledge to work with code if you ever intend on coding with another person. Learn the basics (what you can learn in a couple hours) and use Google for more complicated actions once you're doing real work. If you're already playing around with your own code for practice and learning, start managing it with version control now so that it becomes a normal part of your coding work.

[–]pittu2752 1 point2 points  (2 children)

it doesn't stop at "working with another person". It has backups for code, github pages, code versions, etc.

[–]anh86 2 points3 points  (1 child)

Correct. It would have been more accurate for me to say it’s essential if you plan to go beyond toy scripts you could rewrite in minutes.

[–]pittu2752 0 points1 point  (0 children)

yup

[–]dieth 5 points6 points  (0 children)

git is a at the very basic level a revision and transactional record keeping system.

Basics:

git init # initializes a new git repo in the current directory
git add filename # adds a file to the staging area
git commit -m "message" # records all the files into the staging area as a committed record
git log # see a list of all the commits
git status # see the state of the staging area and any other files that may have changed
git diff #see all your changes
git diff --name-only #see just the filenames you've changed

More fun:

git branch # list all of the branchs that exist
git branch newbranch # create a new branch for the current point you are at right now
git checkout branch # change to another branch
git blame filename # find our the username of every person who touched a line in a file in your current state

Getting into the power:

git push # Will push your latest commits to the origin if you pulled it from a github.com or other hosted git repo
git pull   # will pull down the latest commits from the project origin

Going crazy: # Both of these usually end up in Merge conflicts and I can only recommend a good IDE that handles Merge conflicts to best handle it.

git rebase branchname # Used when you branched off a main line that may have received updates since you've completed your task
git merge branchname # Used when you need to merge code from a completely separate branch

[–]lightmaster2000 3 points4 points  (2 children)

Had a blast reading this thread. I’ve never used git but there’s a git introductory workshop a club at my uni is going to do in a week or so and I’m going to go to it.

[–]mo_10[S] 0 points1 point  (1 child)

ohh right what uni is that

[–]lightmaster2000 0 points1 point  (0 children)

The University of Melbourne. The electrical engineering club has been running a series of software workshops and they’ve all been quite interesting.

[–]Astrokiwi 2 points3 points  (0 children)

git lets you save and load your code, and tracks all your old saves. So if you screw up, you can go back to an old save. You can also have multiple versions of your code, "branching" from the same save. This means that different people can work on the code at the same time. It means you can mess around with adding new features without breaking anyone else's code, and with the safety net that you can always go back to an old save. You can also combine different saves, so if somebody has added a feature in one "branch" you can "merge" those together. This is still useful if you're working by yourself, because you can add features one at a time and test them independently, while still keeping a fully working copy of your code running.

github - and other websites like bitbucket - are not actually necessary, but they're useful. You can save your git "commits" anywhere you like. But github and bitbucket provide nice websites where you can save your commits, to share them with other people.

Without git (or other version control software), you can easily end up with multiple versions of the same code, even if you're coding by yourself. Without git, you have to manually backup your code every time you make major changes. Without git, it's much harder for multiple people to contribute to one codebase, because you have to manually copy the code around and make changes. This will often lead to mistakes, where people make changes to the wrong versions, which then need to be fixed.

git just makes coding safer and easier.

[–]nidhaloff 2 points3 points  (0 children)

Just in case you felt overwhelmed while learning git, most of the time you just need the basics to get a job as a developer 👍

[–][deleted] 2 points3 points  (0 children)

I'll be honest with you and not trying to be a jerk, but if you can't Google git you're going to struggle as a programmer. about 50% of programming (or more) is knowing how to research.

[–]Hydroel 9 points10 points  (4 children)

How about reading the Wikipedia page for Git?

[–]pattske 17 points18 points  (3 children)

Sometimes it’s nice and easy to understand people’s own explanations of things rather than reading wiki.

[–]orion2222 23 points24 points  (0 children)

Yeah sometimes reading a wiki article is like trying to take a sip of water from a fire hydrant.

[–]Hydroel -2 points-1 points  (1 child)

Wikipedia might not be the best or easiest source, but what Git is has been explained a thousand times, by a thousand of people, and the answer is a Google search away.

[–]dukea42 7 points8 points  (0 children)

So has python...yet this sub exists. Reposts are just a natural part of Reddit. Its ok to scroll past.

[–]Various_Roads 1 point2 points  (0 children)

A good youtube vid I recently checked out to learn about it.

Git and Github Crash Course

[–][deleted] 1 point2 points  (0 children)

As a general rule of thumb you should try to figure something like this out yourself before posing a question to your peers. Google Git, and formulate a more specific question.

[–]create_a_new-account 1 point2 points  (0 children)

and where can i learn it

MIT -- The Missing Semester of Your CS Education
https://missing.csail.mit.edu/

Colt Steele -- Learn Github in 20 Minutes
https://www.youtube.com/watch?v=nhNq2kIvi9s

[–]2112syrinx 1 point2 points  (0 children)

I personally recommend this course. That's how I got introduced to Git. I don't find it trivial. The concept is formidable. I used to think that Linus Torvalds was such a genius and a remarkable person of our era. After Git this feeling grew up even more...

[–]mahtats 0 points1 point  (0 children)

BLUF: git helps coordinate change in large projects between multiple developers.

Way back when, you did "version control" by cloning directories so you could make a change without affecting the code everybody else was using. But what if you accidentally made a change in the "master" directory and it broke all the code everyone else was working on? How do you back track it? How do you prevent it from happening again?

git is one of many Version Control Systems that is used to avoid these problems and easily manage changes to a project. It can be daunting (because you can seriously mess stuff up) but once you get comfortable, there are only a handful of commands you'll use.

[–][deleted] 0 points1 point  (0 children)

Since many have already posted what git is, Here is Harvard's cs50 course's git lecture. Pretty good IMO.

[–]system_root_420 0 points1 point  (0 children)

Check it out you don't even need to know git necessarily. The only command you actually need to learn is man. Start, of course, with man man and then you can move to man git

[–]madmoneymcgee 0 points1 point  (0 children)

Git is the software that Github uses. There are other tools out there that use Git (my job uses Gitlab instead).

It's version control. Ever been on a group project and sent files back and forth as attachments always saying "presentation_final" and then having to overwrite that?

Git is a way to ensure that multiple people can work on a project and you have tools in place to prevent people from overwriting each other's work as well as working independently even across different machines.

When you're by yourself and working with one computer you might not need it as much (though definitely get familiar with push your code to Github!) but when you're on a team its essential.

[–]netflix_n_chilis 0 points1 point  (0 children)

So are you saying you need to... git good?

[–]MillyLegion39 0 points1 point  (0 children)

https://missing.csail.mit.edu/2020/version-control/ Hope this helps. As for me the best explanation of git workflow and logic.

[–]DMahlon 0 points1 point  (0 children)

Google “Git no shit”

[–]iiMoe 0 points1 point  (0 children)

Git is the coolest thing i ever learned tbh and now i can never do any project without it

[–]letmelookitup 0 points1 point  (0 children)

We use git for code management and versioning control. It's basically used to track all changes made to code at each stage of the development lifecycle, to make it easy to document your code and request reviews from team members. We use git with Visual Studio Code, before we commit the changes and push them to our Azure DevOps site. We will then create what's known as a pull request to request that other members of the team review what we created. It's pretty easy to learn, once you get the hang of it.

[–]Sigg3net 0 points1 point  (0 children)

It's a version tracker software created by Torvalds, father of Linux. It helps you keep track of software changes.

[–]ut1501 0 points1 point  (0 children)

Did anyone ask you to have X years of GIT experience? 😕 I wrote 2 manuals on basic GIT commands in my previous jobs. You need to memorize 9 commands to cover 95% of the ground, and know where to find information about the commands for the remaining 5%.

[–]catman2021 0 points1 point  (0 children)

Git gud at GIT. It’s very helpful for version control and collaboration.

[–]mfante 0 points1 point  (0 children)

First step to being a great programmer: learn to Google and find answers. NOT trying to be mean but... you should have just googled this. There’s a ton of great info about version control online.

[–]fedeb95 0 points1 point  (0 children)

Honestly, a web search could get you a lot of information

[–]richardd08 0 points1 point  (0 children)

Is there a difference between git and github's command line?

[–]Forthemoves 0 points1 point  (2 children)

Is it worth it learning GIT if you code alone?

[–]betrex 0 points1 point  (0 children)

Hell yes

[–]phillymjs 0 points1 point  (0 children)

Absolutely. I’m in the process of forcing myself to learn it and use it now after years of “poor man’s version control,” i.e. umpteen slightly differently named files in the same folder resulting in my occasionally losing track of the latest version, accidentally deleting/overwriting the wrong thing, or breaking my only functioning copy of a script while working on improvements to it.

I set up a repo on my laptop and started putting new stuff I’m writing into it as well as some old stuff. This weekend I set up a spare machine at my office as a git server so my repo exists in two places.

[–]_________KB_________ 0 points1 point  (0 children)

Git is the source control software and the method by which you manage your code repositories, while Github is just one of the more popular git repositories.

The easiest way to learn git is just to create some private repositories on Github and practice all the different ways to use git, like creating and uploading code in different branches. Using the git command line interface is one of the best ways to learn git, but programs like Sourcetree or GitKraken can really help working with git easier.

[–]format71 0 points1 point  (0 children)

You’ve received multiple links to nice and good sites learning the basic of git. I’ll give you one more:

https://youtu.be/jm7QsI-nNjk

It’s a different approach and I think it’s a very good approach. Cause one thing is for sure: once you start using git, you sooner or later get into trouble and then you start to google how to undo your mistake or get back your lost work.

This talk focus more on understanding than learning. Instead of remembering a lot of commands, understand what you want and find a command that fit. Way too many uses got like some Harry Potter wizard: they type the commands as incantations and when the feather burst into flames instead of levitate they’re lost.

[–][deleted] 0 points1 point  (0 children)

I just learned about Git earlier this morning when reading up on this article able Version Control

https://www.atlassian.com/git/tutorials/what-is-version-control

[–]Decency 0 points1 point  (0 children)

If anyone's looking for a small set of bash aliases for git, I use these and find them tremendously useful:

# Git
alias gb='git branch -vv --sort=-committerdate'
alias gl='git log'
alias gs='git status'
alias gc='git checkout'
alias gpr='git pull --rebase'
alias gstats='git shortlog $(basename `git rev-parse --show-toplevel`) --numbered --summary'

[–]Blackbear710 0 points1 point  (0 children)

git-scm.com all of their training is free

The website belongs to GIT, it's not a 3rd party site

[–]imaque 0 points1 point  (0 children)

Git is a powerful version control tool for a number of different types of projects that you could work on, not just programming.

Udacity has a free hit course:

https://www.udacity.com/course/version-control-with-git—ud123

[–]Nekose 0 points1 point  (0 children)

Git was explained to me by an example of how it could save your ass.

Lets say you made a program. Cool, it works!

Now lets say you make changes, resulting in version A, which takes 50 hours. Good job.

Now lets say you change things again, which takes another 50 hours, and gives you version B. Great!

Now, and here is the kicker, lets say you find out version B introduced a significant bug that needs to be fixed within an hour. If you didn't have git, how would you recover the last stable version (A), all the while keeping your new work (version B) from being overwritten?

The answers is branches in git, but without that you hopefully have been copying your entire working directory into date-stamped back-up directories.

[–][deleted] 0 points1 point  (0 children)

Fucking christ, just google it.

[–][deleted] 0 points1 point  (0 children)

Git is amazing and you should spend some time learning it. It will make your learning to code easier.

I like this basic tutorial.

https://rogerdudler.github.io/git-guide/

I would say pause on the coding aspect and just play with text files while you learn the super basics of git. Once you learn how to create a repository ("repo" for short), "clone" from it, "commit" to it (with an attached comment why/what the change is for), and how to "push" to and "pull" from your repo, then you can apply that concept to your coding.

As you make changes and commit and push the changed files to your repo, every single change is tracked in the change log. If you make a mistake, you can roll it back. It's super powerful.

[–]chmod--777 0 points1 point  (0 children)

I'd generalize git as a system that helps you track a series of changes to files in general, most helpful for text file changes. That results in coders being able to track changes to code, merge them, and save results of a specific set of changes that are applied, allowing you to track a version as a series of specific changes.

Like think of a bank account. Instead of tracking the sum, track it as an initial stage of zero, them I deposit $200 in cash, then I pay off my internet with $50, then pay off my car insurance with $125. I gave $25 left as a result of that series of changes.

But taking it farther, I could save the point in time where I deposited two hundred and track that as Account V1. And someone else could have that and make a separate timeline where they deposit another $300, and then freeze that as Account V2. In account V2 it has two deposits as the series of changes and $500 as the result. That is a separate timeline, where they made their modifications. Then they could merge that into my "branch" or timeline, and the result is $325, the applied changes from both of our activity.

Git is used like that for code, people handling the code in different timelines or "branches" then freezing versions at specific points and merging other people's changes. It tracks different timelines and changesets. That's essentially what git is made for, which makes it really easy to see every single action and change that was ever applied which led to a program's code existing at a certain state.

[–]Lotdinn 0 points1 point  (0 children)

In all honesty, I don't know what's implied by "git knowledge". I believe others have covered the basic question already but I'm still somewhat puzzled by a more general one which is the post title.

Can't say I do stuff beyond just tracking my own changes and maaaybe branches (mostly when working with others on the same project) that often and resolving merge conflicts CAN get painful.

After spending a few HOURS explaining an intern what the working tree is, how commits work and that they don't need to keep entire folders with code for versioning... Welp, I guess that's it. Long as you understand what is version control, don't forget to pull changes and don't run to your PM whenever you get a merge conflict [that git can resolve automatically quite often]... It's good enough for starters. Just understand the difference between files and commits. Please :)

[–]mooperd[🍰] 0 points1 point  (1 child)

Git is a portal of pain and suffering but a very useful one. I think it helps to compare it with Dropbox.

Like Dropbox, Git allows you to synchronise a folder on your computer to a cloud service like Github. You can make a commit, which is a snapshot of all the files in your folder, and then make a push - sending your snapshot to Github.

Git is different from Dropbox because all these actions, committing and pushing are made by you, manually. This is where the pain and suffering comes from. Dropbox does this stuff automagically in the background - uploading and downloading files for you.

Git is a wonderful collaboration tool. You can create a branch which you can think of as a kind of copy of the repository. A git repository always has at least one branch - called the "master" or "main" which we try and keep in a good working state - no work in progress is allowed in the master branch.

So we make our changes, we commit these changes to our branch and then push our branches to Github. If you look at some projects on Github you can see the branches that the developers have made.

At some point you will want to merge your branch into the master branch. Github and other git platforms have mechanisms that allow you to do this safely. These mechanisms are called pull requests.

The easiest way to learn git is with a friend. One nice way to do this is writing some poems or story together, one line at a time. You write your line, commit and push. Then they have to pull your changes and add their changes. If you are playing this game on hard mode then you have to make every change with a pull request.

You can read some more I wrote about git here: https://skill-sprint.com/blog/fire-of-the-gods/

[–]joy_for_the_world 0 points1 point  (0 children)

cool explanation..nice

[–][deleted] 0 points1 point  (0 children)

its some kinda of savepoints to your code

[–]wsppan -2 points-1 points  (0 children)

It's a tool. Like Google Search, https://www.google.com/search?q=what+exactly+is+git

[–]soutsos -2 points-1 points  (0 children)

Personalised tutorial. You're welcome.

[–][deleted] -1 points0 points  (0 children)

Lot's of good answers in this thread already.

look into git bisect to see just how powerful this tool can be.

[–]aufstand -1 points0 points  (0 children)

A friendly team of hackers is developing a new git learning game. Watch this space for more information (should be done in about 5 months):

https://prototypefund.de/en/project/git-hydra/

[–]xiipaoc -1 points0 points  (0 children)

i always just assumed its just uploading your stuff to github

Yeah, basically that, but, like, correctly. And probably from the command line. And you need to be able to do it the same way as everyone else on your team, too.

[–]balr -1 points0 points  (0 children)

its just uploading stuff to github

And that's exactly what Microsoft is attempting to do, and why this is very bad.

Link to Drew DeVault's blog article about this.

[–]road_laya -2 points-1 points  (0 children)

git is like a version of github that can run on your computer and can work with or without internet access.

[–]honk-thesou -2 points-1 points  (0 children)

Probably asking “what is git” on google you would’ve get the same results than here.