DEV Community

Bruno Felipe Silva
Bruno Felipe Silva

Posted on

#01 - How to learn Git from scratch

Yes, you have been coding for quite a long time. You have created your first own app that has the power to change the world forever - or maybe just your local petshop. One day after the great release, a boring and meticulous user sends you a message complaning about a specific feature that doesn't work well. Now you need to fix it, as well as a bunch of another ones you hadn't notice before. Besides that, you have just seen a functionality on your favorite to-do list app that fits just great on your app. Granted, you have to release a new version as soon as possible. But what if the new version spoils some feature that was running good before? Don't panic! That exactly why git and github comes handy! Open up your VS Code on favorite IDE, run the terminal and come along!

1. Initialize a Local Git Repository
The command: git.init
If you have already started your project, type this command on your terminal. It will create a folder called ".git". It can be an existing project directory containing your code files you have been working on or an empty directory where you plan to add your files.
Yes! Now we have a repository to save versions of our project. Uhu!

2. Create a Remote Repository
What is the use of versioning a project which we cannot just share with other devs we are working with? That is why you will need to upload your local version of the project to a remote folder on Github.
So go to Github, sign up for a free account (just in case you haven't done it yet, create a public repository, give it a name and copy its link.
Yes! Now we have a local repository and a remote one on Github.

3. Connect Local Repository to Remote Repository
You might be wandering how to can link the local to the remote repository, right? If so, just run the terminal and type the following command:
git remote add origin
If you have done everything correctly, now you have a local repository working fine and linked to a remote one on Github. They both are now workign together and we can push and pull versions of our app at any time.
Yes, we are almost creating the next facebook app!

Check out the next post!

Top comments (0)