DEV Community

Godfrey Babu
Godfrey Babu

Posted on

GIT AND GITHUB FOR BEGINNERS:HOW TO TRACK CHANGES,PUSH AND PULL CODE

For a data engineering and data science student knowing about git and github is mandatory. Git helps us collaborate with others who we share common interests with. It also helps us track changes in you code and avoid losing your work.

What is git

Git is an open-source version control system that tracks changes made to your files over time, allowing you to go back to a previous version in case of any mistake

What is github

Github is a cloud-based platform where developers store, manage and share their software code.

step 1:Install git bash

  1. Install git
  2. Run installer
  3. Finish installation

verify installation

git --version
Enter fullscreen mode Exit fullscreen mode

Step 2:Setup git

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"

Enter fullscreen mode Exit fullscreen mode

Confirm configuration

git config --list

Enter fullscreen mode Exit fullscreen mode

Step 3.Connect git bash and github through SSH key

ssh-add ~/.ssh/id_ed25519

Enter fullscreen mode Exit fullscreen mode

Add SSH key to github

  1. Go to Github
  2. Go to settings
  3. Click SSH key
  4. Click new SSH key
  5. Paste the key and save

Test connection

ssh -T git@github.com

Enter fullscreen mode Exit fullscreen mode

Step 5.Clone repository

git-ssh-practice.git

Enter fullscreen mode Exit fullscreen mode

Go to project folder

cd git-ssh-practice

Enter fullscreen mode Exit fullscreen mode

Step 6.chek changes with git

Check status:

git status

Enter fullscreen mode Exit fullscreen mode

Add files

git add .

Enter fullscreen mode Exit fullscreen mode

Step 7. Push code to GitHub

Connect local repository to GitHub

git remote add origin https://github.com/username/repository-name.git

Enter fullscreen mode Exit fullscreen mode

Push code

git push -u origin main

Enter fullscreen mode Exit fullscreen mode

Now your code is active on GitHub

Step 8. Pull code from GitHub

This is advisable while working with multiple machines or while working with a team.

git pull origin main

Enter fullscreen mode Exit fullscreen mode

This collects latest changes and updates your local files.

Top comments (0)