Use of Git to push/pull code, track changes and version control

Published: (January 17, 2026 at 01:58 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Ajani Luke Kariuki

Overview

Setting up Git and using it for version control involves a few key steps:

  1. Install Git
  2. Configure your user information
  3. Create a repository
  4. Make commits
  5. Push and pull changes

Below is a detailed, step‑by‑step guide.

Push and Pull

ActionDescription
PushSends your local changes (code or data) to a remote repository (e.g., GitHub).
PullFetches and integrates changes from the remote repository into your local environment.

Set Up Git

After installing Git, configure it with your user name and e‑mail address.

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

Screenshot – Git Config

Git config example

Create a Project Directory

mkdir project1          # create a folder called project1
cd project1             # move into the folder

Screenshots

  • Creating the folder

    mkdir command output

  • Changing into the folder

    cd command output

Initialise a Repository

git init

Screenshots

  • Initialising the repo

    git init output

  • Resulting .git folder

    git folder created

Making Commits

Add Files

git add .

Screenshots

  • Staging files

    git add output

  • Status after adding

    git status after add

Commit

git commit -m "Add readme.md"

Pushing Changes

First, create a remote repository (e.g., on GitHub) and link it to your local repo:

git remote add origin https://github.com/your‑username/your‑repo.git
git push -u origin master   # or main, depending on your default branch

Screenshot – Adding a Remote & Pushing

git remote add & push

Pulling Changes

To update your local repository with new changes from the remote repository:

git pull origin master   # or main

Screenshot – Pulling

git pull output

Recap

StepCommand(s)Purpose
Configuregit config --global user.name "Your Name"
git config --global user.email "you@example.com"
Set your identity
Initialisegit initCreate a new local repository
Stagegit add .Add all changes to the staging area
Commitgit commit -m "message"Record a snapshot
Remotegit remote add origin <url>Link to a remote repo
Pushgit push -u origin masterSend commits to remote
Pullgit pull origin masterBring remote changes locally

Now you have a clean, functional guide for installing, configuring, and using Git for version control. Happy coding!

[![Image 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5x3ffk12ix7cv0sp489t.webp)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5x3ffk12ix7cv0sp489t.webp)

[![Image 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vur0y48fbuv4yxeoy6kp.webp)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vur0y48fbuv4yxeoy6kp.webp)
Back to Blog

Related posts

Read more »

Delving into data science

Introduction This article will help you understand Git and GitHub, including terms like push, pull, tracking changes, and version control. Installing Git Bash...