Skip to main content

Command Palette

Search for a command to run...

Git And Github For Absolute Beginners (Part1)

Updated
0 min read
C

I am an innovative and a creative thinker, adept at coming up with real solutions that works for all. A bright mind who is passionate about furthering his development skills through hands-on-experience.

Translating designs to code and determining developer requirements and collaborating with creative and development teams on the execution of ideas and projects.

I am Competent in the use of JavaScript, React, Redux, HTML5, CSS3, Nodejs, Expressjs to develop a standard, breathtaking and functional web applications.

In this episode, we will look at

  • Installing git
  • What is git
  • How to add git to a project
    • Steps to adding git to a project**
      • Creating a folder
      • Navigating to the created folder
      • Initializing a git repository
      • Adding files
      • Telling git who we are
      • Committing files

Foolish assumptions: I assume you are using windows OS to access this tutorial

INSTALLING GIT

To install git, go to https://git-scm.com/download/win

WHAT IS GIT?

Git is a version control system created by Linus Torvalds the creator of Linux (a popular Unix based operating system). Git help us to manage our repositories; noting what has happened at every interval in a project.

HOW TO ADD GIT TO A PROJECT

We will take step-by-step approach towards adding git to a project

STEPS TO ADDING GIT TO A PROJECT

Step 1. Creating a folder

mkdir git-tutorial

This command will make you a directory called git-tutorial through the command line.

Step 2: Navigate to that folder from the current working directory to our newly created folder

cd git-tutorial

This above command takes us into that folder we just created, which is git-tutorial

Here is where the main journey of asking git to track our changes in the repository begins

Step 3: Initializing a git repository

To initialize a git repository; type git init

git init

git init simply means asking git to start keeping track of all the changes in our repository.

After typing this command, git now tracks all the changes in our folder, the files we add, removed or modified.

But it never stops there, it's just a few steps to a journey of a thousand mile.

If we what to see how our repository now look (i.e its status), git gave us a command to do that

git status

Git will list all the files and folders in the current working directory and their statuses

Status could be any of: added, deleted, modified, tracked, untracked

Step 4: Adding files

Firstly, let us create a file we would like to track with git

echo "Git and Github for absolute beginners" >> git-tutorial.txt

This command will write the text “Git and Github for absolute beginners” into a file git-tutorial.txt

To add file to what git would tract

git add git-tutorial.txt

This will enable git to keep record of even the smallest thing that happen within the file. It could be adding a white-space or removing one, adding a semi-colon or removing one.

Let’s check the status of the repository by typing git status

git status

Step 5: Telling git who we are To be able to successfully tell git to track our files, we have to always let it know the credentials to use. This credentials are our username and email address.

To do that, we have to type for example

git config --local user.name "baby"
git config --local user.email "baby@gmail.com"

Then when committing our files, git will use our username as the name of the committer, and email as the email address of the committer, to store those files.

Explaining the config flags

--local

--local tells git to use this configuration for the current repository

Step 6: Committing files

To commit a file means saving what that happened so far with a particular message relating to what happened.

What happened could be any of: fixing a bug, typo, removing a feature, adding new feature(s) etc.

git commitm “message”

Let say we fixed a typo error, we could type

git commitm “fix typo to enhance code readability”

That's all it takes adding git to a repository.

In our next episode, we will be discussing Git And Github For Absolute Beginners (Part2)

110 views
A

Simple and rich tutorial. That is great

1
C

I'm glad you love it.

1