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

Hi, this is my first time posting here. I’ve been trying to learn git for the past 2 weeks and I’m feeling really frustrated right now. I roughly know how to use GitHub but I’m really confused about git. I tried the udacity course, several youtube videos, tried the code school course on git but still don’t really understand how to use git.

I know most of the basic git commands but don’t know how git really works because all the tutorials keep talking about the commands only or creating new repositories and don’t really show how to link existing projects to git. Most of my projects are all on sublime and I have no idea how keeping track of changes really work on git. I’m feeling super confused right now.

I feel so lost and stupid that I don’t understand git at all.

Now, I’m just wondering do I really need to know how to use git? Can’t I just use GitHub only to work on projects with other people? Or do I really have to know how to use git? Is it necessary for me to be able to keep track of the changes/commits?

Does anyone have any really good tutorials on git? I haven’t totally given up on git yet.

5 Likes

Welcome to the forums!

You’re not stupid because you don’t understand git!

But, it is an essential skill you will need to learn eventually. It’s better that you learn it sooner and it’s great that you’ve already tried.

Now when you said you tried the Udacity course, how far did you get? When you came across something you didn’t understand did you try posting on their forums? You could also post here. Please ask questions when you don’t understand something, people here and on the udacity forums are here to help.

In my opinion, the Udacity (I assume you meant this one) course should be enough to get you on your feet.

6 Likes

Github is just a place to store git repositories (same as Bitbucket or GitLab), with a nice UI and some social features. So you need to use git to use github because github isn’t a thing without it.

Most of the time you only use four commands (git add, git commit, git push to add files and push them up to github, and git pull to pull the latest modified files down). If you’re working on your own, you don’t generally use pull that much, but if you’re working with others, you use it constantly.

git clone clones from a given git repo - you use this when you want to bring a repo from online onto your local machine. git init and git remote add origin when you’re setting up a project locally and linking it to the repo on github.

If you want to track existing projects, make a new repo on github. While it isn’t linked to your local project, it will just show a set of instructions on how to link it - it looks like this:

Locally you do

git init

In the folder for your project. This creates the .git folder that all the changes get tracked in. It’s just a collection of text files that contain the necessary information about the project.

Then you add a remote

git remote add origin https://github.com/YourUsername/your-repo-name.git

Which tells git where the online repo is stored.

Then you normally just do

git add . # adds everything in the project ready to commit
git commit -m 'my first commit' # commit everything, along with with a message
git push origin master # push everything up to github

At that point everything should be set, instead of the GitHub webpage with instructions, you’ll see your project instead.


There’s a GUI client if you don’t want to use the command line: https://desktop.github.com/. Note that if you look on the github UI, there are a few places with a button that says “open in desktop”, for example, under the “clone or download” button dropdown on all github projects - when you click those, it will bring the repo into the GitHub desktop client automatically.

And if you do use the command line (I would strongly advise learning it over GUIs but YMMV), then GitHub have a wrapper around git called hub which makes interaction with GitHub easier - the entire above process can be run entirely from your project root rather than creating a repo first on GitHub:

git init
hub create # creates a repo on github and sets the remote
git add .
git commit -m 'my first commit'
git push

EDIT: when you inevitably type git commit and hit enter, the screen that comes up in the terminal is a text editor called Vim. It is very old, very stable, and powerful, and is designed to be used entirely via keyboard input. But it is horribly cryptic for anyone who has never used it (as an example, the movement commands - h, j, k and l - come from a time before arrow keys were common on keyboards). Here’s a cheatsheet of basic commands.

Help, I am stuck in Vim:

  • Type the character i to enter insert mode. This allows you to actually type text into the editor.
  • Type your commit message - the first line has a max character length, so keep it short. You can type detailed message underneath with no character limit (hit enter, enter at the end of the first line, you want an empty line between the main message and the extra stuff)
  • Once you’re done, hit escape to exit insert mode.
  • Type :wq to save and quit - the colon is saying you want to execute a command, w is for write, q is for quit.
  • If you’ve made an error or just want to get out, type :q!, which will forceVim to quit without saving the commit.
  • You have now escaped Vim.
22 Likes

hub looks cool, thanks @DanCouper!

Thanks! I’ll retake the course again. That was the first course I took and was stuck in the second lesson out of the 4 lessons. They had so many quizzes in that lesson and I felt lost in most of them.

1 Like

Wow, thank you! The problem is that the terminal app gets stuck at git add. It seems like I have a lot of files in my laptop and it seems to be adding everything that I have to the repository instead of choosing particular ones. Am I doing something wrong?

Nevermind, I finally got it :smiley:

2 Likes

Git and GitHub are only intimidating until you start using them, once you do they make a lot of sense!

1 Like

Yes, you have to know it.

No, you are not stupid for having trouble with it. It is a little confusing at first. And even once you get past the first stages of pushing and pulling and such, the workflow of branching and merging with multiple people working can be confusing, even when experienced. Just keep at it and you’ll get it.

2 Likes

Hey,

I am sure anyone who has ever learnt Git has had the same feeling about it - Its confusing.

But here is a tutorial I used to learn all I needed to know. Take a day and go through it and you will be fine.

I still refer to this tutorial when I get stuck or if forget something.

Hope this helps!

2 Likes

I will throw in my 2-cents on this because I feel the most important fact has not been mentioned yet:

If you’re the sole programmer, on a closed source system, no of course you don’t need to know GIT. So one might think, why even bother, my code isn’t being shared ?

Well for one, even if it is in a private repo, if you utilize the GIT methodology it is like having and endless ‘undo’ button on your own code. Normally the Alt-Z privileged dies when the app is closed or the computer turned off. Not so with a properly maintained repository. Even I kind of learned again the deep advantages of this recently as FCC has decided to store student code in the browser cache, and not knowing this I had to reset it. I never ‘cheated’ on the early assignments and from then on on the harder challenges is preserved… But imagine losing all your code.

But, once you accept and become part of a member of a team, not only is your coding position strengthened by your teammates… It also can become a lot more complicated.

So a GIT is not ‘just’ about ‘back-tracking’, it is also about sharing and deciding, as a team, what additions might be fruitful and which may not-- (what ‘fork/push’ is about in a repository) Essentially the core of Agile development and at least what I see as the Scrum-- I actually did play rugby in high school, though we were denied official funds as being ‘too violent’ and had to door-to-door to collect for our ‘club’— I’ve never yet or since played in such a ‘team sport’-- No heros, it doesn’t work like that, it is a ‘team effort’.

So to put it briefly, and maybe just for one’s ‘own’ code-- infinite ‘instant replay’ ? ‘Yes please–’

For working with teams, a democratized means for additions + sharing + backtracking even if an idea is good but doesn’t quite work out-- Also excellent.

Someone else tell me if I am wrong, but this is what GIT means to me.

5 Likes
3 Likes

Knowing any VCS/SCM will do, git is just one of the most popular ones.

1 Like

You can also look into tools such as Git Kraken that make the experience of Git more visual than command line code. It helps to understand the commands and all, but for a visual person like me a GUI Git tool is a life saver.

2 Likes

If you are having problems understanding git itself, I liked the following free online book hosted at the git website https://git-scm.com/book/en/v2. You won’t need to read everything because of how thorough it is. Despite being thorough, It’s still an easier read, and I actually enjoyed it.

Don’t get too down on yourself, it took me quite a while to get git and I’m still learning (and I have 20 years of software development with multiple version control systems). Git is very, very powerful, but as a consequence it does things in ways that are not initially intuitive, simple or even like most of the other version control systems. It sounds to me like you are coming along just fine.

Two bits of advice for what it’s worth. First, always use the command line git commands whenever you can. All of the documentation refers to these commands, and they are the most powerful. The GUIs work, but I think you’ll learn more at the command line. Second, make sure to use git for all your projects and work. Get in the habit of always checking in (and pushing if you are using a server) on a daily basis. Repetition by making it part of your work habit is key.

3 Likes

I would recommend experimenting with just git (minus connecting it to github) using a good GUI for it (I like gitkraken). Make a folder/repo, add a text file, then practice making changes, staging them, committing them, resetting them, etc. That’s how I learned to understand how it works (how it diffs the files and keeps a log, etc). I still keep a practice folder around for testing more advanced commands. Over time I moved to just doing the simple stuff over the command line because it’s faster because I often have it open already (and now Visual Studio Code because it integrates so well with it).

I also remember these two online interactive tutorials helping: Try Git and Learn Git Branching.

Also once you do feel comfortable enough to start using it with projects, learn how to connect it to github or bitbucket and always push before trying out any complicated commands. I learned this the hard way (things deleted from the command line or git do not just get moved to the recycling bin, they are really deleted). But other than that just knowing the basics makes development so much easier compared to the days of “Script 1”, “Script 2”, “Script old”, “Script bla bla bla”, “Script bla bla bla 2”. I cringe at the thought.

1 Like

Thank you for recommending so many useful tutorials to me! I finally understand git(not fully, but definitely more than I did when I created this thread). I always got stuck at the git add . part but now I understand why I couldn’t get past that stage. It’s because I forgot to cd (location of my file) so it always ended up adding all of my files in the desktop and hence it crashed each time.

After having to set up react, I finally understand more about how to use my terminal and make use of the git commands I know. Thank you so much to those who have replied! I’m going to be checking out the resources soon :smiley:

1 Like

Don’t feel stupid! Git is complicated when you start because it is usually
a different kind of thought process than you are used to. I had a pretty
difficult time when I first started using it, and you ABSOLUTELY need to
know it to get a job or freelance. I tried tons of different sites, courses,
videos, etc., trying to learn it.

I finally was able to learn it well enough to be comfortable through this course:

Git Complete: The definitive, step-by-step guide to Git

After you understand the commands and how it works, you can then use a GUI like:

GitKraken

If you want to Git more in depth, try this course:

Git a Web Developer Job: Mastering the Modern Workflow

I hope this helps!

Also, I saw that you mentioned Udacity. I would strongly advise you NOT to use that site.
There are tons of issues with Udacity’s courses that I have found and also read about
from other professionals, so save your money. If you know which courses to pick on Udemy,
you will never need to use another site. I like to pay for a course once, and not a monthly fee
to access multiple courses.

2 Likes

If this would help, a friend of mine recommended this Tutorial

a comprehensive git workflow wiki, forget it’s written specifically for the diaspora foundation.
branching in this wiki is based on a successful git branching model