I don't understand Git and GitHub

I don't understand Git and GitHub
0

#1

I’ve gone through a lot of tutorials and explanations but I still don’t understand anything about Git and GitHub.
I want to save my code to GH every time I make a change but Git just makes things so much more complicated for me than to just save it to my computer and then upload it to GH -.-


#2

GitHub helps for collaboration on projects. What if 10 people are working on the same code? How would you manage that?

It also aids people who want to see your code. There are other version control systems out such as Subversion and MS Team Server.


#3

I started learning Github with Udacity’s course


#4

As a Git newb I understand and I barely even “get it” yet, but I fail to see how typing a few commands into a terminal is harder than saving and uploading manually.

This video helped me understand better: YouTube: Github Tutorial For Beginners


#5

Agreed! I tried on and off for several months and couldn’t “get it” until I came across this Udacity course. I finally “get it” and use it almost daily. Now I’m trying to figure out github pages…


#6

Having tried both the aforementioned Udacity course and a Codeschool one and a Codecademy one, I gotta say nothing did it for me like the actual tutorial that’s listed on fCC (though there’s a new desktop-based version now): https://github.com/jlord/git-it-electron . I didn’t “git it” until I was able to use my own dang text editor and shell on my own machine.


#7

[email protected] for this Git tutorial video link


#8

Last time I used/learn Git was about 3 years ago, via command line, didn’t understand it much, and lost a day’s work when something went wrong during a merge, some kind of conflict and I was trying out different commands, and apparently threw away my day’s work. That kinda left a bad experience for me.

Anyways, I’m back to using Git again this year, watched some YT videos and other video tutorials, and also this time using a WYSIWYG software and that seems to make it easier to visualize what’s where, and if there’s a merge conflict, I think more intuitive what to do next. I’m using SourceTree (for OSX) but am sure there are others for Windows.


#9

I’d like to recommend Git Immersion


#10

NSFW but might be helpful from devRant

I was explaining git and Github to one of my friends during our boring maths class when he asked : “What is the difference between git and Github?”. Just then another friend of mine sitting in front turns out and said : “It’s like the difference between porn and Pornhub”.


#11

Git and especially github confused the hell out of me. I have used svn and sccs (real old school) before, and that made sense to me. The Udacity course on git confused me even more. Eventually I found some very simplistic tutorials on the internet and on youtube, and it started to click. The most comprehensive book on git is free, too. It does have some nice pictures that help a lot with conceptualizing git. I would recommend buying a copy if able. There is something to be said for being able to leaf through a book while sitting at the keyboard.

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


#12

I followed a few tutorials but it didn’t really fully make sense to me until I made my first pull request on an open source project. I recommend finding a beginner friendly issue to work on and get your hands dirty on a real project. There are some projects/organizations on github that are very welcoming to newbies and offer help or guidelines on how to contribute.


#13

Before talking about Github you should first understand what Git is and why it is used. Github is not necessary for Git to be useful although it certainly complements Git especially in team environments.

Imagine you are building a game for example. You might keep all the files for your game (maybe some images, html, css, javascript files, etc) in a main project folder. To develop your game your would typically write small snippets of code and then test them on your local machine. With this being the case you have only one instance of your project at a time. This could lead to some problems:

  1. Say you make some changes, save it, then run your code. Unfortunately, you are now getting a strange error or bug and when you look at your code you are not sure exactly what is causing the problem. Suddenly your whole project is broken. You would like to go back to the way things were, but can’t remember exactly what the code looked like before.

  2. Say you want to try something new out or want to add some new feature to your game. Unfortunately in order to do this you need to start adding code to your currently working project. This is not ideal as if it doesn’t work you will need to backtrack to where it was before you tried to add this feature. Seriously annoying.

Yes, these problems could be solved by saving copies of your project as you work or leaving large blocks of commented code in your editor. This is generally slow, requires organization, and is seriously impractical. Git is a much better solution and solves these problems by allowing one project to flow in several ‘branches’.

Once Git is initialized (‘git init’ is the terminal command) it will essentially watch all the files in its directory - now called a ‘repository’. Upon initialization, git will automatically generate a ‘master’ branch. This is typically your ‘good copy’, the branch that you know works and don’t want to screw up. It is generally not considered best practice to work directly on this branch (although I break this rule often) because you don’t want scenario 1 or 2 (or any other bad scenario that I left out) to occur.

Instead, you would branch off your master. For example, you want to add a new weapon in your game or something. You might use the command ‘git branch new-weapon’. This would copy the state of your master branch to the ‘new-weapon’ branch without needing to physically copy any files. You could now run ‘git checkout new-weapon’ and now you are working in the new branch, not your master.

Now you write some code for your new weapon. Two things might occur:

  1. You realize this new weapon isn’t going to work out, it was a bad idea. In order to go back to your working master copy, all you need to do is run the command ‘git checkout master’ and your folder (and text editor) will magically go back to the way it was when you created the ‘new-weapon’ branch. No need to backtrack.

  2. You make the changes and the new-weapon idea is working and you want to make it your good copy. At this point you would ‘merge’ your ‘new-weapon’ branch into your master branch. Once you do this and everything is good you can go ahead and delete the ‘new-weapon’ branch and be left with just your good copy. The nice thing is that you never risked your master branch at all.

Another essential part of Git is commits. Committing your code is like making a copy of the project at that point, you can go back to it later if you want. Again, Git does not need to copy your whole project to do this.

Although you can commit your code whenever you want, best practice is to do if for every change to the project, not every change to your code. For example, it would be a good idea to commit your code after you repaired a specific bug, but you probably wouldn’t make a commit for every line of code that you wrote to fix that bug.

git also supports a long list of nice commands which give you info about your project.

‘git status’ will let you know what files have changed since your last commit.
‘git diff’ will show you the lines of code that have been changed since the last commit.
‘git branch’ will show you all the branches of your repository.

There is much more to Git than I have written, but these are some of the reasons why it is so useful. It is basically a tool that will save you time in the long run.


Do I really need to know how to use git?[SOLVED]
#14

This visual description of how to work with Git and GitHub made a lot of things click for me. It describes the why and the what.

simple guide to forks in github and git

As for the How, there are also two links on the page that shows the specific commands you need.


#15

This is so far the easiest tutorial I’ve seen, and it helps me understand the benefit of using git. Try using it for a while and you will see why everyone’s using it.


#16

I totally second @DWAbrego - I tried about 10 different places/things before I found this book and now it’s all coming together.

Side note: I feel like a lot of the “learn Git in 15min” type things are like making chocolate cake from a boxed mix - sure it might turn out okay, but it’s not going to help you when you only have raw ingredients or are trying to impress Mary Berry :cake:
:smile:


#17

This is also how I learned git. Great course!