Skip to main content

Command Palette

Search for a command to run...

🚀Day:8 A Beginner's Guide to Git, GitHub, and Version Control🚀

Day 8 of 90Days of Devops Challenge

Updated
5 min read
V

Experienced QA professional with a passion for manual and automation testing. Proficient in DevOps practices, ensuring seamless integration and continuous delivery. Dedicated to ensuring top-notch software quality and efficiency. Eager to contribute my skills to Hashnode's vibrant tech community. Let's collaborate and create exceptional experiences!

🌟Introduction

Welcome to this blog post, where we'll delve into the world of Git, GitHub, and version control to gain a clear and straightforward understanding. Git serves as a version control system, streamlining code management by effectively tracking file changes. On the other hand, GitHub acts as a web-based platform, providing a collaborative space for hosting Git repositories and fostering developer cooperation. By the time you finish reading this guide, you'll have a solid grasp of the fundamentals, be well-equipped to install Git on your computer, set up a GitHub account, and master key version control tasks. Let's get started!

💾What is Git?

Git is a version control system that aids developers in effectively managing their code. It facilitates tracking file changes, collaboration with teammates, and reverting to previous versions when necessary. In contrast to conventional approaches of storing multiple file versions, Git operates in a decentralized manner, enabling seamless collaboration among multiple developers on the same project.

🤝What is GitHub?

GitHub serves as a web-based platform, offering hosting services for Git repositories. It enables developers to store their projects, collaborate with team members, and share code with the broader developer community. GitHub enhances Git's capabilities by providing a user-friendly interface and incorporating features such as issue tracking and pull requests.

🔍What is Version Control & Types of Version Control?

Version control is a way to handle changes in code as time goes on. It helps developers keep track of modifications they make, work well together with others, and keep a record of all the changes they've done. With version control, things like going back to old versions, figuring out who did what, and combining code from different team members become easy and smooth.

Two primary types of version control systems :

  1. Centralized Version Control: In this system, all the project's code is stored on a central server. Developers fetch files from this central repository, make changes on their local computers, and then submit their modifications back to the central server.

  2. Distributed Version Control: In this system, each developer possesses a complete local copy of the project's code, along with its entire history. This approach allows developers to work independently on their computers and later share their changes by synchronizing with remote repositories.

🌐Advantages of Distributed Version Control over Centralized Version Control

Distributed version control, exemplified by Git, brings significant advantages over centralized systems. These benefits include:

  • Offline Work: Developers can work on their local repositories even without internet connectivity, which is not possible in centralized systems.

  • Faster Operations: Most operations in distributed version control are faster as they are performed locally, without relying on a central server.

  • Redundancy and Backup: Since every developer possesses a complete copy of the repository, data loss risks decrease, and backups are readily accessible.

🚀Git Installation & GitHub Account Creation

To begin using Git on your computer, follow these steps:

a. Download Git from the official website: https://git-scm.com/downloads

b. Install Git by running the downloaded installer and following the on-screen instructions.

c. Once installed, open a terminal or command prompt and verify the installation by typing: git --version

Windows:

Linux:

To create a GitHub account: follow these simple steps:

a. Visit https://github.com/

b. Click on the "Sign Up" button and follow the instructions to make your account.

After completing these steps, congratulations are in order! You have successfully installed Git and created your GitHub account. Now, you can begin sharing and collaborating on your projects. 🌟🤝 Let your coding journey begin!

📝Exercise 1:Creating a Repository

a. Log in to your GitHub account.

b. Click on the "New" button to create a new repository.

c. Provide a name, description, and optional details for your repository.

d. Click "Create repository" to establish the repository.

📂Exercise 2:Clone the Repository to Your Local Machine

To clone a repository, follow these easy steps:

a.Open your computer's terminal or command prompt.

b.Go to the folder where you want to save the cloned repository. You can use the cd command to get there.

c.Find the web address (URL) of the repository you want to clone on GitHub. You can get it by clicking the "Code" button on the repository's page and copying the URL.e.g: github.com/your-username/your-repository.git

d.In the terminal or command prompt, type git clone followed by the copied URL. It will look like this:

git clone <repository-url>

Press "Enter" to start the cloning process. Git will copy the repository to your computer.

Once it's done, you'll have a copy of the repository on your computer, and you can start working with the files.

🔄Exercise 3:Make Changes, Commit & Push to GitHub

a. Open the cloned repository on your local machine.

b. Make changes to a file using any text editor.

c. Save the changes and open a terminal or command prompt in the repository folder.

d. Use the command: git status to view the changes you made.

e.Add the changes to the staging area using: git add filename OR git add & check the status and file is now tracked.

f.Commit the changes with a descriptive message:

git commit -m "Your message here"

g.After committing changes, push them to the GitHub repository using:

git push origin master

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

🎉Conclusion

Congratulations! You now possess a basic understanding of Git, GitHub, and version control. This guide has equipped you to install Git, create a GitHub account, and perform essential version control tasks. Utilize this knowledge to collaborate with others, efficiently track changes to your code, and contribute to open-source projects on GitHub.

Happy git-ing!🚀🚀

Thank you for taking the time to read this blog. I hope you found the information helpful and insightful. So please keep yourself updated with my latest insights and articles on DevOps 🚀 by following me on :

Hashnode: vishaltoyou.hashcode.dev

LinkedIn: linkedin.com/in/vishalphadnis

So, Stay in the loop and stay ahead in the world of DevOps!

Happy learning 🚀😊🐧📦🔧🛠️💻💼🔍📈🚀🌟📊📚