DEV Community

Cover image for From Zero To Intermediate Git
Joseph Mania
Joseph Mania

Posted on

From Zero To Intermediate Git

Git is a version control system where you can save and share your code online. This is one of the tools each developer should have in their toolbox. It's through GitHub that people can work in different locations but on a similar project. The push, pull, commit are essential keys in the daily life of a programmer.

Essential requirements
First, download gitbash, which is the command prompt of git. It's very simple to install. If you hate using commands, then download git for desktop, its standalone software with multiple buttons. But it's preferable to know the commands because some functions are not yet on the desktop application.

Creating a Github account and repository
Go to GitHub.com and create a free account. Using the guidelines, you can update your profile. Then, on the right hand, next to your profile, choose repository and click on the plus sign to create a new repository. Choose your name and choose either public or private. For very sensitive projects, choose a private repository so that only the people with whom you share a key can access them. But for most of your dummy or open-source projects, select the public domain. Let it stay logged in.

Common daily commands for developers
If your Gitbash was installed successfully, open it. Go to the folder where your project is located. Copy the path. Don’t copy the folder but the path. Just click on the folder once, before it opens, you will see at the top of the explorer the option of "copy path"We are back in gitbash. Use PWD to confirm if it's working and use the following basic command to save your project online

git init
This is the first command to create a git track in your app. project. So whenever you want to push the request next time, or you make any changes, your project is being tracked by that folder created. Remember, the command git init is done once for a single project. Even if you are pulling a project from Github, just know they have a tracker.

git status
The command checks if any changes have been made. Or if you haven’t pushed it will show the files added and changes made on various files. You will get untracked message. It's not compulsory to run the command, but it's good if you want to check if your git has been updated up to the last minute.

git add . / git add
I use git add . in my daily life. It adds all the files being tracked to the local repository. Please, don’t forget the dot after 'add and space'. If you want to specify the file, then use git add followed by the filename. eg git add school.html.

git commit –m “First commit”
In most cases, you will see the word, first commit, but it’s a variable name that you can change. This command sends all the added files to the local repository to update everything. Hi there, you can let the process run until it is completed and bring a message.

git remote add origin
Here we go, go back to the repository, copy the link generated. If you can't see the link, just click on the blue button ‘CODE’, you will get a pop-up GitHub link to your empty repository. Then inside the gitbash write git remote add origin followed by the link. It has to run successfully. Meaning they have linked up with the online server.

git push origin –u master
Here we get to know the last basic command. You have to transfer your project from the git local repository to an online server where you can access it while at any place. Run the command and live for a minute or less. Make sure you have a strong Wi-Fi connection if your project is too large.

If you receive any errors, kindly reach me for assistance on my social media accounts. Get me on Facebook, Twitter, or Instagram. Also, feel free to email me directly.

Top comments (0)