Code Monkey home page Code Monkey logo

master-git's Introduction

Master Git

Master the concepts of Git with me through a set of tutorials


What is Git ?

  • Distributed Version Control System

What is GitHub ?

  • A GUI for hosting the Git folders/repositories/projects online to share, collaborate and contribute from around the world
  • Other Platforms: BitBucket, GitLab

Why are we using Git and GitHub?

  • Maintaining the history of the project versions
  • To track changes made by each person
  • Share the project around the world

Download Git


Basic Linux commands

  • ls
    • Lists all the files and folders at present directory
  • ls -a
    • Lists all the hidden files and folders as well
  • ls .git
    • Lists all the files and folders inside .git folder
  • mkdir project
    • Create a folder named project
  • cd project
    • Changes directory to project folder
  • touch names.txt
    • Create a file named touch.txt
  • vi names.txt
    • Opens the vim editor for names.txt file
  • cat names.txt
    • Displays all the content in names.txt file
  • rm -rf names.txt
    • Deletes the names.txt file

Where does Git store information ?

  • The information like history, versions and so on are stored in another folder that git provides us.
  • This is known the git repository
  • This folder is named .git
  • In Linux file systems, the folders preceded with . are hidden

How does Git store information ?

  • At its core, git is like a key value store.
  • The Value = Data
  • The Key = Hash of the Data
  • You can use the key to retrieve the content.

Git Commands

  • git init
    • Initializes empty git repository in the current working directory
  • git status
    • Know more about the changes made in the project
  • git add names.txt
    • Adds names.txt file to the staging area
  • git add .
    • Add all of the files in the staging area
    • . means add all of the files/folders
  • git commit -m "names.txt file added"
    • Commit all the files
    • -m means to provide a message to the commit
  • git restore --staged names.txt
    • Restores the changes made since previous commit from the staging area
  • git log
    • Displays the entire history of commits
  • git reset [hash value of the commit]
    • Removing a commit from the history of a project
  • git stash
    • Save the progress somewhere else (like a backstage) and make the present working directory clean
  • git stash pop
    • Bring back the changes saved (from backstage)
  • git stash clean
    • Just deletes all the changes saved (from backstage)
  • git remote add origin [GitHub Repository URL]
    • Attach local Git project to GitHub Repository
  • git push origin main
    • Share the changes from local project to remote repository

Analogy to understand Git

  • Consider a scenario of a wedding
    • 1 The Guests go the stage
    • 2 Photographer takes their picture with the couple
    • 3 The photos are saved in a wedding album
  • Now, assume that the guests who have not taken their picture with couple yet as the Untracked files
  • 1 Hence we take their picture by bringing them to stage => The untracked files are added to the staging area
  • Now, we need to permanently save the picture in history
  • 2 Hence the photographer takes their picture with the couple => The staged files

Resources

master-git's People

Contributors

aswinbarath avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.