DEV Community

Derrick Kimanthi
Derrick Kimanthi

Posted on

IMPLEMENTING GIT BASH, BEGINNER-FRIENDLY GUIDE

INTRODUCTION

In this guide, I will explain the basic uses of git bash. In a simple, beginner-friendly manner.

Git bash installation

  1. Open your browser, e.g chrome, microsoft edge e.t.c

  2. Search for Git Bash download on the browser to download the setup file.

  3. Run the .exe file to install.

  4. Make sure you check the launch gitbash icon before installing.

Connecting Git Bash with GitHub

To connect git bash to git hub, we use a set of command lines. I will explain the steps in a beginner-friendly manner for easy understanding.
After installation, open Git Bash

  1. To check the installation and version, we use the following command: git --version and then press enter. You should be able to see the version number. ## Configuring Git
  2. We need to update your name and email. This connects git bash to your GitHub Profile.
    You will run the following commands separately
    First, it's the name; git config --global user.name "YOUR NAME" and press enter. Second, run the second command for configuring the email: git config --global user.email "Your Email@gmail.com"

  3. Confirmation of the configured details;
    Run the following command; git config --list
    You should be able to see your user name and email as seen below:

    You should be able to see your user name and email

Establishing a connection between git bash and git hub

To connect GitBash to GitHub securely, we need to generate an SSH key.

An SSH key is an access credential used by the Secure Shell (SSH) protocol to provide secure, passwordless authentication between two systems. In this case, between Git Bash and Git Hub.

  1. Generating an SSH key
    Type the following command: ssh -keygen -t ed25519 -C "your Email" Then press Enter.

  2. Starting the SSH agent
    What this agent does is securely hold your private SSH key in memory to avoid you entering the passphrase each time you make an SSH connection. In short, it connects automatically when GitBash needs to make a connection with GitHub.
    Run the following command eval "$(ssh-agent -s)" and press enter

  3. Adding the SSH key.
    Type the following Command: ssh-add ~./ssh/id_ed25519, press enter. In Windows, the key is mostly saved in the local disc C inside the users folder, where you will find the SSH sub-folder. There are two keys: the private and public keys. Whereby the public key goes to your GitHub.

  4. Adding the SSH key to GitHub

  • Open the private key location.
  • Open the key and copy it using a text editor of your choice e.g visual code studio.
  • Open gitHub click the profile, and scroll down to find settings.
  • Click the SSH and GPG Keys. Paste the copied key and save.
  1. Testing the connection between GitBash and GitHub. To test the connection, run the following command: ssh -T git@github.com You should be able to see the following:Hi username! You've successfully authenticated.

What is Version Control?

This is a system that tracks changes made to files overtime.
The functions of version control are:

  • Backup- prevents loss of work
  • Enhances collaboration if you are working with a team.
  • Lets you undo mistakes.
  • Tracks progress of your projects.

Basic git workflow

Most projects have the following workflow:

  • Modify files in your repository.
  • Stage changes adding snapshots to your project using git add
  • Commit the changes by adding descriptions that describe: who made the change? What time was the change made? Why was it made?
  • Pushing your local commits to your GitHub repo git push
  • Pulling changes made by other members to update your repository git pull

Understanding Push and Pull

The term push and pull refers to git commands that are simply used to upload and download changes made to your code (projects) remotely. This is crucial as it backs up your project as well as makes collaboration easy.

The git push command is used to send the committed changes to your GitHub repository.
The git pull command is used to download content from a remote repository.

Conclusion

Understanding Git Bash and Git Hub is very important, as both of these combined provide a realible and effective method to manage projects, enhanced collaboration and easy tracking of changes. Therefore for a beginner developer understanding these tools is crucial.

Top comments (0)