Deep Dive in Git & GitHub for DevOps Engineers

Deep Dive in Git & GitHub for DevOps Engineers

  1. Overview to Git & GitHub

What is Git and why is it important?

  • Git is a distributed version control system, It allows multiple developers to work on the same codebase simultaneously, keeping track of changes, managing versions, and facilitating collaboration.

  • Used for version control, collaboration, etc

What is the difference between Main Branch and Master Branch?

  • "Master branch" is the older term historically used in Git.

  • "Main branch" is the newer term that some projects and organizations are adopting to promote inclusivity and remove any connotations associated with the term "master".

Can you explain the difference between Git and GitHub?

  • Git is a distributed version control system (DVCS) that tracks changes to files and coordinates work among multiple people on a project.

  • GitHub is a platform built around Git that provides hosting for software development version control using Git.

How do you create a new repository on GitHub?

  • Log in to GitHub: Go to GitHub and log in to your account.

  • Create a New Repository. Click on '+' icon in the top right corner of the page.

  • Set Up the Repository.

  • Create Repository: Click the "Create repository" button.

What is the difference between a local & remote repository? How to connect local to remote?

  • A local repository resides on your local machine. It's where Git stores all the files and metadata for your project.

  • A remote repository is hosted on a remote server (like GitHub, GitLab, or Bitbucket). It serves as a centralized location where your project can be stored and accessed by team members.

  • Create a Remote Repository, follow previous step.

  • Initialize Git in your Local Repository,

linux$ git init
  • Add Remote Repository URL,
linux$ git remote add origin <remote_repository_url>
  • Push to Remote,
linux$ git push -u origin main

This command pushes the 'main' branch (or whichever branch you are currently on) to the 'origin' remote repository.


  1. Task 1 : Set your user name and email address

    Q. Set your user name and email address, which will be associated with your commits.

# Create directory
linux$ mkdir git && cd git

# Initialize directory as Git repository
linux$ git init

# Setup username 
linux/git$ git config --global user.name "Ojas Jawale"

# Setup user email
linux/git$ git config --global user.email  "ojasjawale1010@gmail.com"

linux/git$ git config user.name
Ojas Jawale

linux/git$ git config user.email
ojasjawale1010@gmail.com

Task 2 : Push changes to remote repository

  • Create a repository named "DevOps" on GitHub.

  • Connect your local repository to the repository on GitHub.
linux/DevOps$ git remote -v
origin  git@github.com:ojasjawale/DevOps.git (fetch)
origin  git@github.com:ojasjawale/DevOps.git (push)
  • Create a new file in Devops/Git/Day-02.txt & add some content to it.
linux/DevOps$ cat Git/Day12.txt
This is changes from local to remote repo
  • Push your local commits to the repository on GitHub.
linux/DevOps$ git add Git/

linux/DevOps$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   Git/Day12.txt

linux/DevOps$ git commit -m "Added New Content"
[master 7329b91] Added New Content
 1 file changed, 1 insertion(+)
 create mode 100644 Git/Day12.txt
shuhari@debian:~/linux/DevOps$ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 372 bytes | 186.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To github.com:ojasjawale/DevOps.git
   4bf5973..7329b91  master -> master


Connect Me

LinkedIn | GitHub

Follow me for more amazing content :)