#Day8: 90DaysofDevOpsChallenge Basic Git & GitHub
TABLE OF CONTENTS
Introduction
What is version control?
What is Git?
What is GitHub?
Why do we use distributed version control over centralized version control?
Let's now perform a practical task based on the theory above.
Create a new repository on GitHub and clone it to your local machine:
Make some changes to a file locally and commit them to the repository using Git.
Pull the changes back to the local machine from the repository on GitHub.
Introduction:
Welcome to the Basic Git & GitHub Challenge. Git is like a time machine for your code, helping you track changes and collaborate effectively. GitHub is your magic place on the internet for storing code, working with others, and showcasing projects. In this 90-day challenge, we'll start with the basics and progress to advanced concepts, making Git & GitHub mastery a breeze.
What is version control?
Version control, also known as source control, is the practice of tracking and managing changes to software code. Version control systems are software tools that help software teams manage changes to source code over time. As development environments have accelerated, version control systems help software teams work faster and smarter. Version control helps them to reduce development time and increase successful deployments.
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.
With Git, you can keep a record of who made changes to what part of a file, and you can revert to earlier versions of the file if needed. Git also makes it easy to collaborate with others, as you can share changes and merge the changes made by different people into a single version of a file.
What is GitHub?
GitHub is a web-based platform that provides hosting for version control using Git. where developers can store and manage their code effortlessly! 🌟 As a subsidiary of Microsoft, GitHub offers all the distributed version control and source code management (SCM) functionality of Git, combining it with its awesome features. It's no wonder why GitHub is the go-to choice for countless developers to share and collaborate on projects. From open-source masterpieces to private repositories, GitHub caters to all your coding needs with a user-friendly interface.
Why do we use distributed version control over centralized version control?
Better collaboration: In a distributed version control, 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.
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.
Greater flexibility: With a distributed version control, 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.
Enhanced security: In a distributed, 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.
Overall, the decentralized nature of a distributed version control allows for greater collaboration, flexibility, and security, making it a popular choice for many teams.
Let's now perform a practical task based on the theory above.
Task-1: Create a new repository on GitHub and clone it to your local machine
Go to your GitHub account (If you don't have GitHub account then, You can sign up at https://github.com.
Click On New (Right side green button) and create a new repository, Please refer to the below image.
In the next step, we will clone this repository into our local machine. 🖥️💻
Open Your Git ( if git is not installed on your pc then, You can download it from the official website at https://git-scm.com/downloads).
Create one folder on your desktop and open gitbash and clone the repo.
check git is installed or not using the command git --version
Clone the repo : git clone <repo url>
Open gitbash
Make some changes to a file in local and commit them to the repository using Git.
Currently, our repository is empty. Please go to your local machine and make 1-2 changes by creating files in the respective directory.
Now type the below commands,
First initialise the git using the command git init
- Stage the Changes: Use the
git add.
command to stage the changes you want to commit. For example, if you modified a file called "example.txt".
Commit the Changes: Committing records the changes you made to the file in the Git history. Use the git commit -m "Your commit message"
command with a commit message describing the changes.
Push Changes to the Repository: If you cloned a remote repository and want to update the remote repository with your changes, you'll need to use the git push -u origin main
(here, main is your branch name)command.
NOTE:- During the push command, it prompts for the password so log in via the same GitHub credential.
Pull the changes back to the local machine from the repository on GitHub.
Pull Command: you can use the git pull origin -v main
command, which is a combination of git fetch
and git merge
. This command fetches the remote changes and automatically merges them into your current branch.
We can also use separate git fetch
and then git merge origin/main.
Useful commands
Feel free to reach out if you have any questions or need further assistance🚀 by following me on Hashnode, LinkedIn(https://www.linkedin.com/in/chakradhar-tatikonda-303b491a6).
Thank you!!
Subscribe to my newsletter
Read articles from chakradhar thatikonda directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
chakradhar thatikonda
chakradhar thatikonda
DevOps Engineer | Automation and Infrastructure Experienced DevOps engineer actively seeking new opportunities and collaborations in the exciting world of DevOps. Skilled in implementing CI/CD pipelines, optimizing deployment processes, and leveraging cloud technologies for scalable and resilient systems. Passionate about driving innovation and continuous improvement. Let's connect and explore how we can revolutionize software delivery together!