DEV Community

Blinton Kiarie
Blinton Kiarie

Posted on

GIT BEGINNERS GUIDE(understanding version control and how to push and pull a code)

UNDERSTANDING GIT VERSION CONTROL

Git is one of the version control systems used to track changes in files or set the files over time
For Git to work perfectly it needs platforms that host it's repositories online for various reasons like collaboration, management etc
There are various platforms that host git repositories but the commonly used platform is GitHub

Git and GitHub installation and connection

First check if you have git installed by simply going to your command system and type the below command

git --version
Enter fullscreen mode Exit fullscreen mode

If not installed you can simply go to your browser and search git and make sure you install it according to the operating system your machine is using e.g windows, linux, mac
next step is setting up your username and email using the below codes

git config --global user.name "yourname"
git config --global user.email "youremail"
Enter fullscreen mode Exit fullscreen mode

Check settings using the below code

git config --list
Enter fullscreen mode Exit fullscreen mode

The next step is connecting your git to your repository platform for our case we will be connecting to GitHub
To connect your git to your GitHub you have to have created an account with GitHub
So simply go to your browser and search for GitHub then sign up with your Gmail account, enter your details i.e name, email, bio, location etc
So connecting your git to your GitHub you need to generate and SSH KEY using your Git by entering the below command

ssh-keygen -t ed25519 -C "your email"
Enter fullscreen mode Exit fullscreen mode

Start SSH Agent by using below command

eval "$(ssh-agent -s)"

Enter fullscreen mode Exit fullscreen mode

after generating it copy the SSH KEY and link it with your GitHub account by
just simply go to your GitHub account, click your profile, go to settings, click on SSH and GPG keys, click on new SSH key and paste the generated SSH key.

HOW TO PUSH AND PULL A CODE

In order to push a code you first Check what changed by using the below command

git status

Enter fullscreen mode Exit fullscreen mode

the next step is adding the file for the changes by using the following command

git add .

Enter fullscreen mode Exit fullscreen mode

then you can easily write what you changed by using this command

git commit -m "Describe what you changed"

Enter fullscreen mode Exit fullscreen mode

next thing is Pushing the file to the remote repository. for our case we are using github

git push origin main

Enter fullscreen mode Exit fullscreen mode

The next thing is how to pull the code to download the changes we've made

git pull origin main

Enter fullscreen mode Exit fullscreen mode

Conclusion
This just a beginner friendly article
on the basic overview of git
by an aspiring data analyst
thank you

Top comments (0)