Basic Git & GitHub for DevOps Engineers.

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 back 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. 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 own features. GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects

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

Version control is a system that tracks changes to a file or set of files over time so that you can recall specific versions later. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.

There are two main types of version control systems: centralized version control systems and distributed version control systems.

  1. A centralized version control system (CVCS) uses a central server to store all the versions of a project's files. Developers "check out" files from the central server, make changes, and then "check-in" the updated files. Examples of CVCS include Subversion and Perforce.

  2. A distributed version control system (DVCS) allows developers to "clone" an entire repository, including the entire version history of the project. This means that they have a complete local copy of the repository, including all branches and past versions. Developers can work independently and then later merge their changes back into the main repository. Examples of DVCS include Git, Mercurial, and Darcs.

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.

    Overall, the decentralized nature of a DVCS allows for greater collaboration, flexibility, and security, making it a popular choice for many teams

  • Git Download

  • Create a free account on GitHub (if you don't already have one). You can sign up at https://github.com/

  • Why Git is Important?

    Imagine you're working on a big puzzle with your friends, and each of you has a copy of the puzzle pieces. Git is like a magic box that helps you and your friends work on the puzzle together, even if you're not in the same place.

    Here's how it works:

    1. Snapshots: Git takes pictures of the puzzle as it changes. These pictures are called "snapshots" or "commits." Each snapshot shows how the puzzle looks at a particular moment.

    2. Saving Changes: When you and your friends add, move, or take away puzzle pieces, Git notices those changes and takes a snapshot to remember what was done.

    3. Teamwork: Git makes it easy for you and your friends to share your snapshots with each other. If one friend finishes their part of the puzzle, they can share their snapshot, so others can see what they did.

    4. No Losing Work: Git is like a super smart memory. If someone accidentally messes up the puzzle, Git can help fix it by going back to an earlier snapshot. So no work gets lost!

    5. Try New Ideas: Git also lets you and your friends experiment. You can make a copy of the puzzle, try out different pieces, and if it works, you can show everyone. If not, no problem – you can go back to the original snapshot.

In real life, Git helps programmers work on software together, just like you and your friends work on the puzzle. It keeps track of changes, helps people collaborate, and ensures that everyone's work fits together nicely in the end. So, Git is like a super helper for teamwork and not losing any hard work!

  • What is the difference Between Main Branch and Master Branch??

    Tutoriel Git : git branch

    Imagine you're working on a group project, like building a treehouse with your friends. The "main branch" and "master branch" are like different versions of your treehouse as it's being built.

    • Main Branch: This is the main path everyone is using to build the treehouse together. It's like the blueprint that everyone follows. Any changes or improvements that people make are added to this main plan.

    • Master Branch: This is a super special version of the treehouse that's considered really stable and ready. It's like the finished treehouse that you're all super proud of. Once your treehouse is perfect and safe, you put that version in the "master branch."

In simpler words, the "main branch" is where all the work is happening, and the "master branch" is the best, most polished version that everyone agrees is complete. It's a way to organize and make sure the project is going smoothly, just like building a treehouse with your pals!

  • Can you explain the difference between Git and GitHub

    Git is like a magical bookmark that remembers every version of your story as you make changes. It's like having a time-traveling notebook.

    GitHub, on the other hand, is like a library where you can store your story and share it with others. You can invite your friends to read, make changes, and even work on the story together. GitHub makes it easier for people to collaborate on writing the story, like a team of writers working on the same book.

    So, Git helps you keep track of your changes, and GitHub is a place to store and work on your project with others

  • Link: How do you create a new repository on GitHub?

Difference between local & remote repository

Git Remote | Learn Git

Local Repository: A local repository is like your personal workspace. It's a folder on your own computer where you keep all the files and changes related to your project. When you work on your project, you make changes in this local repository. It's like your own private playground where you can experiment, create, and modify things without affecting anyone else.

Remote Repository: A remote repository is like a shared hub. It's stored on a server, which is usually on the Internet. This repository is where you and your team members store your work to collaborate. When you want to share your changes with others or get their changes, you do it through this remote repository. It's like a central place where everyone's work comes together.

In simple terms, the local repository is where you do your individual work, and the remote repository is where you all come together to share and combine your work.