Basic Git & GitHub for DevOps Engineers.๐Ÿš€

ยท

3 min read

Basic Git & GitHub for DevOps Engineers.๐Ÿš€

What is Git?

Git is a Version Control System that Keeps track of all the changes or modifications made to the files by different people.

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 features.

What is Version Control?

It is the system that tracks all the changes made over time.

Types of version control systems:

  1. Centralized Version Control System (CVCS)

  2. Distributed Version Control System (DVCS)

Centralized Version Control System (CVCS)

A Centralized Version Control System (CVCS) uses a central server to store and manage versions of files. Developers check in and check out files.

Distributed Version Control System (DVCS)

Distributed Version Control System (DVCS) allows developers to "clone" an entire repository. They have a Full local copy, including history.

Why do we use distributed version control over centralized version control?

  1. Better collaboration: In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don't have to constantly communicate with a central server to commit their changes or to see the changes made by others.

  2. Improved speed: Because developers have a local copy of the repository, they can commit their changes and perform other version control actions faster, as they don't have to communicate with a central server.

  3. Greater flexibility: With a DVCS, developers can work offline and commit their changes later when they do have an internet connection. They can also choose to share their changes with only a subset of the team, rather than pushing all of their changes to a central server.

  4. Enhanced security: In a DVCS, the repository history is stored on multiple servers and computers, which makes it more resistant to d

Difference Between Centralized and Distributed Version Control Systems

Git Installation ๐Ÿ› ๏ธ

Git Installation on Linux๐Ÿง:

  1. Install Git using the package manager (Ubuntu):

     sudo apt update
     sudo apt install git
    
  2. Once the installation is complete:

     git --version
    

After this, It should display the version.

Git Installation on Windows๐Ÿ–ฅ๏ธ:

  1. Go to the Git for Windows website gitforwindows.org

  2. Click on the Download button to download the latest version of Git for Windows.

  3. Once the download is complete, double-click on the downloaded file to start the installation process.

  4. Once the installation is complete, open the command prompt to verify whether Git is installed :

     git --version
    

After this, It should display the version.

Create a new repository on GitHub

  1. Go to GitHub and log in to your account.

  2. Click on the "+" sign in the upper right corner and select "New repository."

  3. Fill in the repository name and description.

  4. Click on the "Create repository" button.

Clone the repository to your local machine ๐Ÿ–ฅ๏ธ

Open your terminal and navigate to the directory where you want to clone the repository.

git clone <repository_url>
cd <repository_name>

Make changes to a file๐Ÿ“

  1. Open the file you want to change using a text editor or an IDE.

  2. Make your desired changes to the file.

Commit the changes๐Ÿšง

git add .

git commit -m "Your commit message here"

Push the changes back to GitHub๐ŸŒ

git push origin master

Replace master with the branch name if you are working on a branch.

Now, if you refresh your GitHub repository page, you should see the changes reflected there.

ย