Doubt about Visual Studio Code and Git

So I´m finally trying to learn how Git/Github actually works and I have this doubt:

When I´m using Visual Studio Code each time I do a change in the code, there´s this tab which is named “Source Control”. Inside it you can “commit changes” everytime you change something in the code.

My question is, obviously I haven´t linked my account or any repository with VSC, so what is the purpose of that tab then? And If there´s no purpose, how can exactly link a repository to the project im working on VSC?

If I do “git clone” inside the project folder im working on that will be enough to use the Source Control tab in VSC so it will be syncronized to my repository in github?

Don’t confuse Git with GitHub; Git existed long before GitHub.

Git is a (distributed) version-control system for tracking changes in source code.

GitHub is a cloud-based hosting service for source code, that hosts Git repositories.

Note! Git is one of many version-control systems, other options are available such as Subversion or Mercurial. These also work inside VScode and if you were using either of those, I guess you’d still be getting notifications from your ‘source control’ tab in VSCode.
GitHub is also just one of many hosting services that can host Git repositories, it just so happens that Git is currently the most popular version-control system for managing source-code revision history and GitHub is the most popular hosting service for Git repositories.

This leads many people believe they are one and the same thing, or somehow tied into each other, but they are only related in the same way that ‘source code’ is related to (for want of a better example).

Alone, Git enables local source control; it’s good to have revisions of your work and a commit history, even if you’re not sharing or working on the source code with other developers, hence why a source control option exists in VSCode, regardless of whether you’ve connected to GitHub yet, or not.

You have probably issued the git init command or enabled a ‘local’ git repository somehow, whilst learning VS code / Git. Local repositories are stored inside a .git folder, which is located inside your project folder (they are hidden by default, at least on macOS), this is where your commit history is being saved, and why you are getting prompts from VSCode.

To answer your question, git clone would be a command that you would use when you want to clone a repository that is hosted on a server (including GitHub), to your local machine. Similarly, you could clone a local repository to another location on your system, a network share, perhaps, so that you could work on the same project with someone else on your home network.

I think it’s important to understand the basics of Git and have an understanding of the basic commands before thinking about GitHub, I’d recommend reading the first few chapters of this free resource to get a running start. I assure you, it will be a very well spent 1 or 2 hours of your time!

You would not use git clone to sync your code “to” GitHub, that is not the purpose of git clone. There are some initial steps that need to be taken to set up a new repository on GitHub, and once complete you would use git push and git pull (along with a few other commands) to keep the changes in sync.

If you want to get a head start in GitHub i’d suggest their own learning labs. However you need to learn basic Git structure and commands first!


Thanks for the long reply!

I already completed codeAcademy git courses, an 1 hour youtube tutorial on Git, and the first tutorial of Github and still didn´t get it … I think I´ll be a pro in React+Redux before understand Github lol… but I guess with time I will. I´ll check that resources, thanks.

1 Like