Hello everyone! It's time again for a small blog post. Today I'm going through all git commands that I regularly use in my coding projects. In this tutorial, I'm assuming that you never used git before. So feel free to skip the fundamental parts. For that, you can use my table of contents. Just click on the desired topic, and enjoy reading it. Let's get started!
What is Version Control?
Imagine you are currently working on a new python project. After you've written your first lines of code, you save the file under the name "first version" and decide to work on the project tomorrow. On the next day, you continue to add new lines of code to the file, but you completely screw it up. The whole script is not working anymore, and you get to the point where you just want to burn this version and get back to the previous one. Thankfully, you set up git in your project, which version controls your code files. This means you can easily roll back to earlier versions of your project if you happen to screw up some things in your code files.
Pretty cool 😎.
So git basically helps you to keep control over your project versions.
How to Setup Git for Your Project
To set up git for your project, you have to navigate to your project's folder via the command line.
For those who are new to bash, by using the command cd, you can dive into folders. Simply write cd, and then the name of the folder you want to enter.
To list all folders and files in a directory, type ls. The rest you can find out by yourself ;)
Assuming you reached your projects folder, use the following command to initialize git.
Congratulations 🥳, you've just created your first git repository. If you want to see the .git, just type ls -a. This will list all files and folders, including the hidden ones like the .git file.
Now the question is, how can we start tracking our files in our working directory (this is where your project files are located) using our previously initialized .git repository.