WHAT IS GIT?
The simple sentence to describe Git is to describe it as an Open Source Distributed Version Control System. Its really a simple sentence but all encompassing.
Breaking it down...
Distributed Version Control System: This basically means that Git is a content tracker. So Git can be used to store content — it is mostly used to store code due to the other features it provides. Git has a remote repository which is stored in a server and a local repository which is stored in the computer of each developer. This means that the code is not just stored in a central server, but the full copy of the code is present in all the developers’ computers. Git is a Distributed Version Control System since the code is present in every developer’s computer at different locations around the world.
The code which is stored in Git keeps changing as more code is added. Also, many developers can add code in parallel. So Version Control System helps in handling this by maintaining a history of what changes have happened.
Version control system like Git is always needed to ensure there are no code conflicts between the developers.
Additionally, the requirements in such projects change often. So a version control system allows developers to revert and go back to an older version of the code.
HOW TO START UP WITH GIT
With the assumption that the system has Visual Studio Code running on it, Download git:
The link below has details on how to install Git in multiple operating systems:
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Open Visual Studio Code as ADMINISTRATOR
As annotated, go to the three dots, select Teminal, Select New Terminal
A terminal, an interface to run command will be created as below
Run the following commands on the terminal...
git version (To confirm that git is installed on the system)
git status (To know the status of git and confirm if there is any pending commit)
git config --global user.name "username" **eg "Presh2005" as used
**git config --global user.email "email address" eg "preciousinsight2@gmail.com" as used
mkdir folder name to create a folder to work with eg GitLabPresh
git init to make the folder GitLabPresh a repository folder for git to operate...ie put git in it. This will create a .git hidden folder in GitLabPresh folder.
From VSCode, Go call up the GitLabPresh Folder to work with as below
and create the file you want to push to the remote repository in the folder.
Note the content in the file Presh.docx
Call up a new terminal as below, click on the dropdown to select the code editor of your choice
Issue the the following commands...
git.status - comfirm that there is a change yet to be committed ie Presh.docx
git add . - this is to add the file Presh.docx
git commit -m "commit message" - this is to save the changes in git
Go to www.github.com to create a repository in which Presh.docx will be resident
Copy The Link Of the remote Repository
Issue a git push command using url of the remote repository. This action creates a file or sends the changes to the replica file on the remote repository
The committed file Presh.docx reflects on the remote repository and the content is the same as the one in the local repository
We will add the content below to file in the remote repository and save.
from the remote repository
i can edit and i am confirming that your clain it true
Keep it up
Your are a good Devops engineer in the making
Kindly note that you can now collaborate with your colleagues using GIT
No git! No Collaboration!! No Devops
Weldone
From VSCode, issue a git pull command to track changes at the remote repository. These changes immediately reflect on the Presh.docx above
Conclusively, it is clear that the steps to get starting with git, to create local and remote directories, to commit change from any vantage, and to pull or push across the repository is simpler than one would have thought of.
On this note, happy reading.
Top comments (0)