DEV Community

Trizah Ogeto
Trizah Ogeto

Posted on

Introduction to Git Bash, GitHub, and Version Control

1. Introduction

In today’s technology world, developers and data analysts work on projects that change often. Files are updated, mistakes happen, and sometimes we need to go back to an earlier version of our work. This is where Git, Git Bash, and GitHub come in.

Git is a version control system that helps track changes in files.
Git Bash is a terminal that allows Windows users to run Git commands easily.
GitHub is an online platform where Git repositories are stored and shared.

In this article, I explain how to install Git Bash, connect it to GitHub, use Git Bash commands, pull code from GitHub, and understand version control.

2. Installing Git Bash on Windows

Git Bash is required to use Git commands on a Windows computer.

Steps to install Git Bash:

  1. Open a web browser

  2. Search for Download Git Bash

  3. Open the official website official website

  4. Download Git for Windows

  5. Run the installer

Keep the default settings and click Next until installation is complete

How to confirm installation:

Right-click anywhere on your computer

Select Git Bash Here

If a terminal window opens, Git Bash is successfully installed

3. Configuring Git Bash

After installation, Git must be configured with your name and email. This information is used to identify who made changes to files.

Commands used:

Name("git config --global user.name "Your Name")
Email("git config --global user.email "your@email.com")

To confirm the configuration:

Confirm("git config --list")
This command displays the saved Git configuration details.

4. Connecting Git Bash to GitHub

Git Bash can be securely connected to GitHub using SSH keys.

Step 1: Create a GitHub account

create

Sign up or log in if you already have an account

Step 2:Generate an SSH key

In Git Bash, run:

code to run("ssh-keygen -t ed25519 -C "your@email.com")

Press Enter to accept default options

Step 3:Add SSH key to GitHub

Copy the SSH key:

code to SSH key("cat ~/.ssh/id_ed25519.pub")

Go to GitHub → Settings → SSH and GPG keys

Click New SSH key

Paste the key and save

Step 4: Test the connection

Test connection("ssh -T git@github.com")

If the connection is successful, GitHub will confirm authentication.

5. Basic Git Bash Commands

Below are common commands used when working with Git Bash:
| Command | Purpose |
| pwd | Shows the current folder |
| ls | Lists files in a folder |
| cd foldername | Moves into a folder |
| git init | Initializes a Git repository |
| git status | Checks file changes |
| git add . | Stages all changes |
| git commit -m "message" | Saves changes |
| git log | Shows commit history |

6. Tracking Changes Using Git

Tracking changes is one of Git’s most important features.
Steps to track changes:

git status
git add .
git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

whereby
git status checks file changes

git add . prepares files for saving

git commit saves a snapshot of the project

This process allows developers to keep a record of every change made.

7. Pulling Code from GitHub

Git Bash allows users to download and update code from GitHub.

Clone a repository("git clone git@github.com:username/repository.git")

Pull latest changes("git pull")

These commands ensure the local project is always up to date with the remote repository.

8. Understanding Version Control

Version control is the process of managing changes to files over time.

It helps to:

  • Track changes
  • Collaborate with others
  • Recover previous versions
  • Prevent loss of work

Git acts as the version control system, while GitHub stores projects online for collaboration and backup.

9. Conclusion

Git Bash and GitHub are essential tools for developers and data analysts. Git Bash allows users to interact with Git through commands, while GitHub provides a platform to store and share projects. Understanding version control makes it easier to track changes, collaborate, and work efficiently. Learning these tools is an important step toward becoming a skilled technical professional.

Top comments (0)