Basics of Git&Github for DevOps Engineers

Basics of Git&Github for DevOps Engineers

What is Git?

Git is a version control system tool that is used for source code management version control system(VCS) is a software tool that is used to keep a record or manage any type of changes, updates or modifications that happened during the development of software.

In a version control system version is nothing but indicates a specific point where changes have been applied and whenever any developer made any changes to the software a new version of the software will generate it also helps to identify the point where changes have been done or done by whom here in the history of version control system developers can check of any prior version of the software and can modify the changes

Why it's important?

  1. Git is the most commonly used version control system it tracks the changes you make to your file or repository(folder)

  2. the repository is nothing just the folder of your working project where your files it is the centralized location for developers and contributors to make modifications

  3. Git is a speedy and efficient distributed VCS that can handle projects of any size

  4. Git allows multiple developers to work independently without interrupting each other and send files back and forth constantly or merge changes manually

Difference between Git & GitHub

Git -

git is a version control system that allows developers to manage changes to their code Git will install into your local system

Github -

GitHub is a platform or software that provides hosting for git repositories. hosting nothing just gives you access to store your local repository in the remote repository or remote server Additionally, GitHub provides a web-based interface for viewing and managing code as well as several additional features such as issue tracking, managing pull requests, merging etc

What is the difference between local & remote repository

The local repository is a Git repository that stored on your computer system or the local machine

The remote repository is a git repository that is stored on remote computers or remote servers these are hosted on a server that is accessible to all the team members - most likely the internet

What is Branch in Github?

A branch in GitHub is a particular version control feature that is used to separate the work or changes of developers for their codebase which facilitate the developer to make separate work module for their branch without interrupting the main codebase or Branch (default or Master branch ) and when the modification is done by developer then the branch will be merged

How to connect the local repository to the remote repository?

  1. Go to github.com and log in to your account.

  2. Click the “New repository” button.

  1. Enter a name for your repository and add a brief description. Choose whether you want the repository to be public or private.

  2. Choose repository visibility. Click on the public if you want your repository to be cloned by anyone.

  3. Click the “Create repository” button.

Steps to connect :

  1. Set your username and email for configuration to authenticate with Github Account

    to do so you can use the following commands

    git config — global user. name “<name>”

    git config — global user. name “<email id>”

    to check the user credentials :

    git config — global user.name

    git config — global user.name

  2. Create a repository named "DevOps" on Github

  1. Connect your local repo to your remote repo on GitHub

    to connect your local repository on github you first need to initialize a new git repository on your local machine to do this navigate the directory where you want to initialize repo use the command :

    git init

Add the files in your local repository

here I create two files name Git.tx using vim editor and another file file2.txt usin touch command (refer linux basics)

now i add both the files to staging area -staging area is nothing just the space or area to track all the changes made in your local repo before doing any changes in your remote repository you have to add all the changes to staging area first the commit

git add .

Commit the files that you've staged in your local repository.

git commit -m "my first commit"

Copy remote repository URL field from your GitHub repository, in the right sidebar, copy the remote repository URL.

In Terminal, add the URL for the remote repository where your local repostory will be pushed.

git remote add origin <remote repository URL>

Push the changes in your local repository to GitHub. use the command “git push origin master” to push your local commits to the remote repository on GitHub.

Now successfully connected local repository to remote repository on Github