Introduction to Git, GitHub, and Version Control workshop-o-matic Library

  • Thread starter Thread starter JohnAziz
  • Start date Start date
J

JohnAziz

Learn the basics of working with Git, GitHub, and Version Control in just 1 hour


In this Student Ambassadors event, available on-demand by clicking the preview below, you are going to get to know all about version control, install git, work on a local repository, work with remotes on GitHub, and finally, you are going to work on another developer’s repository.

Access the Workshop
workshop-library/full/intro-git-github-version-control/README.md at main · microsoft/workshop-library

Learn how to run the workshop




What is Version Control?


Let's start with a little story, once upon a time there were two friends playing a game together this game consists of the world map and small pieces that you use to conquer a piece of land. Each player starts moving his pieces and the player that conquers the biggest piece of land wins. The game takes a lot of time as the players are trying to conquer the whole world so, sometimes they pause the game and continue playing the next day. Instead of restarting the game each time, they thought of a nice solution which is to keep track of the game state by taking an image of the game board each time they stop playing.


large?v=v2&px=999.png
This image has the time included in it, who took the image, and the state and location of game pieces in the image which ensures that they always have a safe point they can get back to.


To sum up, the content of a safe point is the following:

  • Time
  • Who took it
  • State and Location of Pieces



This idea of a safe point is exactly what version control is, as you keep track of the different versions of your code which might include the time, the person who created the version, and the state of your code at that exact time.



Types of Version Control Systems


There are two types of version control systems:

  • Centralized Version Control Systems (CVCS): only one device has everything (each device has its own piece of the centralized code).
  • Distributed Version Control Systems (DVCS): each device has the same version of the code (all the devices are contributing to it at the same time).

large?v=v2&px=999.png



Most Popular Version Control Systems

  • Git: uses a distributed version control system.
  • Subversion: uses a centralized version control system.
  • Mercurial: uses a distributed version control system.



Difference between Git and GitHub


When you hear about git you may mix between it and GitHub so, to clear the confusion

  • Git is a version control tool that doesn’t require GitHub to work.
  • GitHub is a cloud platform for hosting and sharing Git Projects.

large?v=v2&px=999.png



Terminologies


There are lots of terminologies out there that we might hear about when starting to learn about git and GitHub like Merging, Version Control Systems, SHA, Branching, Conflicts, Remotes, Source Code Manager, Commit, Repository, Index, Staging, Checkout, and Repo.

All of these terminologies are actually used while working with git, but you don’t need to learn about all of them at the beginning at the same time If you prefer learning everything before starting the practical part this git-cheat-sheet-education (github.com) is perfect for you.



How Git Works?


To get started, you have to understand the difference between these three places or virtual places.

You have the working directory in which you can create your files, and you have the staging area which is the intermediate place between saving the changes forever in the local repository or leaving them in an intermediate state in the working directory but what can you do to ship your changes to the staging area?

Imagine you have a cruise trip the first thing you do is load the ship with your luggage or bags, in order to load the ship with your files or code, you can use a command called git add and then you give it the name of the file.


For example, you can say git add new-text-file.txt which will move your file to the staging area, or the staging index which is the intermediate place that you have learned about.

large?v=v2&px=999.png



In order to do the next step which is moving the file to the local repository you have to use a command called git commit which makes your changes saved in git's history. So, to make your changes there you can use git commit and you give it a message.


For example, “Message” is any message you want but this message is really important as it helps anyone get a brief understanding of the changes you did to sum up, there is a command called git commit and you give it a -m to specify a specific message, and then double quotations surrounding your message then the file is saved in the local repository.

large?v=v2&px=999.png



How does Git work with GitHub?


Again How does git work? but now with GitHub?

There is something new that has been introduced to you here which is the remote repository and for our situation the remote is GitHub. This remote repository can be used to host our code online so, you can ship your code not just to your local repository but also online to the cloud to share it with others either in a private repository or a public repository which is open to everyone for contribution and to move your code from the local repository to the remote repository you have to use a command called git push!

large?v=v2&px=999.png



What if it’s the other way around, you did some changes on the remote repository and want to see these changes locally? you can use another command called git pull. Git pull will take the version of the repository that is hosted on GitHub and download it to your local repository.

large?v=v2&px=999.png



This workshop was hosted as part of the Workshop-o-Matic Grab & Go Content, built by Cloud Advocates and their colleagues in partnership with Microsoft Student Ambassadors.


✨ What's a 'grab-and-go' workshop? It's something you can 'check out' of this library and CUSTOMIZE IT to your community's needs, interests, and language. You can deliver these workshops verbatim, or totally rearrange them and their assets to suit your needs! ✨

You can get more than 30 workshops all on-demand at aka.ms/workshopomatic.


Don't stop learning

- Learn more about GitHub on Microsoft Learn.

- Finish Introduction to version control with Git learning path.



Found this useful? Share it with others and follow me to get updates on:


Continue reading...
 
Back
Top