Day 8: Basic Git & GitHub for DevOps Engineers.

Day 8: Basic Git & GitHub for DevOps Engineers.

What is Git?

GIT is a popular distributed version control system used for software development and is widely used by developers for managing source code and tracking changes made to it over time.

GIT allows multiple developers to work on the same codebase simultaneously and merge their changes together seamlessly. It also provides features for branching and merging code, enabling developers to work on separate features or fixes in isolation and then merge them back into the main codebase when they are complete.

GIT uses a decentralized architecture, which means that each developer has a complete copy of the codebase on their local machine, as well as access to the complete history of changes made to it. This makes it easy to revert changes, track down bugs, and collaborate with other developers.

What is Github?

GitHub is a web-based hosting service for software development projects that use the Git version control system.

GitHub provides a platform for developers to host, manage, and share their code with others. Developers can create and manage repositories, which contain the code for their projects, and use Git to track changes made to the code over time.

GitHub also provides features for collaboration, such as pull requests and code reviews, which allow developers to review and comment on each other's code before it is merged into the main codebase. It also provides tools for issue tracking and project management, enabling developers to keep track of bugs, feature requests, and other tasks related to their projects.

What is Version Control? How many types of version controls do we have?

Version control, also known as revision control or source control, is the management of changes made to computer code, documents, websites, or any other collection of information.

It allows multiple people to work on the same code base or document simultaneously, and track changes made over time, making it easier to collaborate and maintain a record of revisions.

There are two main types of version control systems:

  1. Centralized version control system (CVCS)
  2. Distributed version control system (DVCS)


  1. Centralized version control system (CVCS): In a CVCS, there is a single centralized server that stores the codebase or document and each developer has a working copy on their local machine. Developers make changes to their local copy and then commit those changes to the central repository.

2. Distributed version control system (DVCS): In a DVCS, every developer has a complete copy of the codebase or document on their local machine and there is no central server. Developers can work independently, making changes and committing them to their local repository. They can then synchronize their changes with other developers by pulling and pushing changes between repositories.

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 data loss. If the central server in a CVCS goes down or the repository becomes corrupted, it can be difficult to recover the lost data.

TASK : Install Git on your computer

  1. Update the package manager’s cache by?

No alt text provided for this image

2. install Git using the following command:

No alt text provided for this image

3. verify that Git has been installed by running the following command:

No alt text provided for this image

TASK: create free account on github

To create a free account on GitHub, follow these steps:

  1. Go to the GitHub website at https://github.com/.
  2. Click on the "Sign up" button in the top-right corner of the page.
  3. Enter your desired username, email address and password.
  4. Choose to sign up for a free individual account.
  5. Complete the CAPTCHA verification to prove you are not a robot.
  6. Click on the "Create account" button.
  7. GitHub will send you a verification email to confirm your email address. Open the email and click on the link to verify your account.
  8. Once your account is verified, you can customize your profile and start using GitHub.


TASK : Create a new repository on GitHub and clone it to local machine, Make some changes to a file in the repository and commit them to the repository using Git also Push the changes back to the repository on GitHub

Steps to create a new repository on GitHub, clone it to your local machine, make changes to a file, commit the changes, and push them back to the repository on GitHub,

  1. Log in to your GitHub account.
  2. Click on the "+" icon in the top right corner of the page and select "New repository".
  3. Give your repository a name and a brief description, select whether it should be public or private, and then click on "Create repository".
  4. On your local machine, open a terminal or command prompt and navigate to the directory where you want to clone the repository.
  5. Copy the repository's URL by clicking on the green "Clone or download" button on the GitHub repository page.
  6. Run the following command, replacing "repository URL" with the Actual-URL you just copied, This will clone the repository to your local machine.

No alt text provided for this image

7. Navigate to the cloned repository directory by running the below command Replace the repository-name with actual name”?

No alt text provided for this image

8. Make some changes to a file in the repository using your favorite text editor

9. Run the below command to stage the changes,

No alt text provided for this image

Replace "file-name" with the name of the file you changed.

10. Commit the changes by running the following command,

No alt text provided for this image

Replace "Commit message" with a brief description of the changes you made.

11. Push the changes back to the repository on GitHub by running the following command

No alt text provided for this image

You may be prompted to enter your GitHub username and password.

These above commands will stage your changes, commit them to your local repository, and push them to the remote repository on GitHub.

Suraj Rampure

.NET|.NET CORE | ASP.NET | MVC | SQL | WEB API | Micro services |GIT| Docker

1 年

Nice

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了