Basic Git & GitHub for DevOps Engineers.

1.What is Git?

Git is a version control system that allows you to track changes to files and coordinate work on those files among multiple people. It is commonly used for software development, but it can be used to track changes to any set of files.

2.What is Github?

GitHub is a web-based platform that provides hosting for version control using Git. It is a subsidiary of Microsoft, and it offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects.

3.What is Version Control?

Version control is a system that tracks changes to a file or set of files over time so that you can recall specific versions later. It allows you to revert files back to a previous state

3.How many types of version controls we have?

There are two main types of version control systems:

a) Centralized version control systems

  1. A centralized version control system (CVCS) uses a central server to store all the versions of a project’s files. Developers “check out” files from the central server, make changes, and then “check in” the updated files. Examples of CVCS include Subversion and Perforce.

b) Distributed version control systems.

A distributed version control system (DVCS) allows developers to “clone” an entire repository, including the entire version history of the project. This means that they have a complete local copy of the repository, including all branches and past versions

4.Why we use distributed version control over centralized version control

a)Better collaboration

b)Improved speed

c)Greater flexibility

d)Enhanced security

Tasks:

1)Install Git on your computer/server/Instance

  • Using Ubuntu Server

run command : sudo apt-get install git -y

2)Create a free account on GitHub.

You can sign up at https://github.com/

Learn the basics of Git by reading through the video This will give you an understanding of what Git is, how it works, and how to use it to track changes to files.

Exercises:

1.Create a new repository on GitHub and clone it to your local machine

You can store a variety of projects in GitHub repositories, including open- source projects. With open-source projects, you can share code to make better, more reliable software. You can use repositories to collaborate with others and track your work

i)In the upper-right corner of any page, use the + drop-down menu, and select New repository.

ii) Create a repository and give a proper name to it.

iii) Optionally, add a description of your repository. For example,” I will be posting all the DevOps learning in this Repo”

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

iv)Select Initialize this repository with a README.

v)Click Create repository.

2. Cloneing it to your local machine

Go to your repository copy the code of your repository

Now go to your machine and run below command :

# git clone https://github.com/shri14/myrepo.git

# ls

Make some changes to a file in the repository and commit them to the repository using Git***.***

4)Make some changes to a file in the repository and commit them to the repository using Git.

Open the Git bash from the folder /repo you wish to add to the version control system(git)

i)git add . Add the files to your new local repository. This stages them for the first commit.

ii)git status To show the status of the git repository. This command displays the state of the local directory and the staging area.

iii)git commit -m “msg” Commit the files that you’ve staged in your local repository

iv)git push Push the changes in your local repository to GitHub.com.

Thank you for reading! Hope you find value from this article please do follow and click the clap 👏 button below to show your support 😄.

Shrikar