Mastering Git and Github: Essential Information (Part 1)

ยท

4 min read

Mastering Git and Github: Essential Information (Part 1)

Introduction

Ever accidentally overwritten important code? Wished you could rewind and go back to a previous version of your project? Well, fret no more! This blog will introduce you to Git and GitHub, powerful tools that will revolutionize your workflow.


Git and Github

What is Git?

Git is a distributed version control system that helps developers track changes in their codebase. It allows you to save snapshots of your project at different points in time, making it easy to revert to previous versions if needed. With Git, you can work on your code locally, create branches to experiment with new features, and merge changes seamlessly.

What is Github?

GitHub, on the other hand, is a platform built on top of Git that adds social and collaborative features. It serves as a central hub for hosting Git repositories, making it easy for developers to share their code with others, collaborate on projects, and contribute to open-source software. GitHub provides tools for code review, issue tracking, and project management, making it an essential tool for both individual developers and teams.


Why git and github?

Why git?

  1. Version Control: Git allows developers to track changes made to their code over time. This means you can easily revert to previous versions if something goes wrong, compare changes between versions, and collaborate with others without fear of losing work.

  2. Collaboration: Git facilitates collaboration among developers by providing a platform for sharing and merging code changes. Multiple developers can work on the same project simultaneously, and Git helps manage conflicts that arise when different people make changes to the same files.

  3. Branching and Merging: Git enables developers to create branches to work on new features or experiment with changes without affecting the main codebase. Once the changes are tested and approved, they can be merged back into the main branch, ensuring a smooth and organized development process.

  4. Backup and Recovery: By using Git, developers have a complete history of changes made to their code, stored locally on their machines and remotely on Git hosting platforms like GitHub. This serves as a backup in case of data loss or system failures, allowing developers to recover their work easily.

  5. Open Source Collaboration: Git has become the de facto standard for open-source projects, enabling developers from around the world to contribute to software projects. Hosting platforms like GitHub provide a centralized location for sharing code, managing issues, and collaborating with the global developer community.

Why github?

  1. Centralized Repository Hosting: GitHub provides a centralized platform for hosting Git repositories. This means you can store your code in one place accessible from anywhere with an internet connection. It simplifies collaboration by allowing multiple developers to access, contribute to, and manage codebases easily.

  2. Community and Collaboration: GitHub fosters a vibrant community of developers, making it easy to discover, contribute to, and collaborate on open-source projects. It offers tools for issue tracking, code review, and pull requests, enabling seamless collaboration among team members or contributors from around the world.

  3. Project Management and Documentation: GitHub offers features for project management and documentation, such as wikis, project boards, and README files. These tools help organize and communicate project goals, tasks, and guidelines effectively, making it easier for teams to coordinate their efforts and for new contributors to onboard quickly.


Installation & setup

  • Install git on your comouter. It is available for all operating system.

  • Create account on github.

  • Create an empty repository on github.

  • Now you can start with git.

First Git command

  • After installation search on your machine "git bash", It is a git terminal used to work with git using commands or you can open you terminal.

  • The next thing you need to do is to write the git -v or git --version command on your terminal. It will print the version of the git that you have installed on your system.


Git configuration

Git configuration lets you personalize how you work with Git. It involves setting various options that control Git's behavior. These options are stored in text files called .gitconfig.

There are three main levels of configuration:

  • System-wide: Applies to all users and repositories on the machine.

  • Global: Specific to your user account and applies to all your repositories.

  • Local: Applies to a single Git repository.

Common configurations include setting your username, email for commits, preferred text editor, and even creating aliases for frequently used commands.

You can use the git config command to view, edit, and set these configurations. There's also a git config --list command to see your current configurations.


Conclusion

The main purpose of this blog is to help you grasp the fundamental theoretical concepts of Git and GitHub. I hope you find it enjoyable. If there's anything that raises questions, please let me know by leaving a comment.

ย