Git and GitHub Tutorials

Some theoretical staff

First of all, what are those terms?

Git is an open source project, which refers to something people can modify and share because its design is publicly accessible, originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel.


GitHub is a website and cloud-based service that helps developers store and manage their code, as well as track and control changes to their code.

It is really quick

Easy to use

Distributed

Git

So, let's start with the prerequisites​

  • First, install Git from https://git-scm.com/.
  • Then, insert the cmd folder from Git (which looks like that: C:\Program Files\Git\cmd) into the path variable from Windows.

Then, let's switch to some basics

  • You can see the git version in cmd with:
    Git –version
  • And you can update it directly in that cmd with:
    Git update – deprecated
  • Then going into our directory, open cmd and give the following command:
    git init
  • In order to see the status, in cmd give the following command:
    git status
  • In order to include a new file from that folder into staging you give the following command:
    git add {file name}
  • If you are wandering what Staging is, you can think of it like nearly exact replica of a production environment
  • In order to register in remote repository the updates you can insert in the command line:
    git commit -m “{text}”
  • In order to see the modifications history in that repository give in cmd the following command: 
    git log
  • In order to add all files that are not tracked use in cmd:
    git add .
  • In order to restore some files that you accidentally removed from the folder use:
    git restore {file name}
  • In order to overlook some files in the repository, make a new file without name and with .gitignore and you can just edit with a text editor and add the files you want to be ignored. 

  • In order to ignore all files with a certain extension, insert in the 

  • .gitignore file *.{extension}

  • Note: In .gitignore we call also add folders
  • In order to see all the branches you can give the next command:
    git branch (master is the main one)
  • In order to add a branch you have to insert:
    git branch {branch name}
  • In order to switch between branches you can give the following command:
    git checkout {branch name}
  • In order to create and switch to that branch you can insert:
    git checkout -b {branch name}
  • In order to delete a branch you insert:
    git branch -d {branch name}
  • In order to merge the current branch with the master one (the main one) you have to put:
    git merge {current branch, not master branch}

GitHub

Here everything is simple
  • You can start by creating a repository.
  • Then, follow the steps here (image below).
  • Always when you have a modification in the local, if you want to be in the remote you have to use:
    git push

  • Always when you have a modification in the remote, if you want to be in the local you have to use:
    git pull
  • If you want to see in local if there are some modifications in remote, you can use:
    git fetch
  • Note: if there are modifications you can see some logs, if they are not, you are good.
  • If you want to pull everything from a repository into your local one use:
    git clone {URL}
The only way to evolve is the continuous desire to learn, regardless of the nature or subject.
Emilian
Author

Check their official websites

Git

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

GitHub

GitHub is a web-based version control and collaboration platform for software developers. So, It lets you and others work together on projects from anywhere. 

Welcome to the footer

Thank you for making it this far! 🙂 With the hope that you have ‘digested’ a large part of the materials made available, I promise you that I will come with even more content when time permits. See you soon!

Copyright © 2024. Rotaru Emilian Teodor

Copyright © 2024. Rotaru Emilian Teodor