Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git And Github

Git And Github

Demonstration of Git and github tools

Abhishek Singh

August 25, 2017
Tweet

Other Decks in Programming

Transcript

  1. WHAT IS VERSION CONTROL SYSTEM • A version control system

    (VCS) allows you to track the history of a collection of files. • Version control (or revision control, or source control) is all about managing multiple versions of documents, programs, web sites, etc. • A system that keeps record of your changes. • Allows for collaborative development. • Allow you to know who made what changes and when. • Allows you to revert any changes and go back to a previous state. • Non-distributed (Subversion, CVS) • Server has the master repo, all commits go to the server • Distributed (Git, Mercurial) • Server has the master repo, but you have a copy (clone) of the repo on your machine. • No Central authority. • Everyone has the complete history. • Everything is done offline(except push/pull). • Changes can be shared without a server
  2. WHAT IS GIT • Started in 2005. • Created by

    Linus Torvald to aid in Linux kernel development. • Git is currently the most popular implementation of a distributed version control system. • Git is a Command line tool. • Everyone has the complete history • Everything is done offline(except push/pull). • Changes can be shared without a server. • No central authority. • Goals of Git: • Speed • Support for non-linear development.(thousands of parallel branches) • Fully distributed • Able to handle large projects efficiently
  3. BASIC GIT TERMINOLOGY • Repository aka repo • A Git

    repository contains the history of a collection of files starting from a certain directory. • Consists of all your Commits and a Place where all your hard work is stored. • Snapshots • The way git keeps track of your code history. • Essentially records what all your files look like at a given point in time. • You decide when to take a snapshot and of what files. Have the ability to go back to visit any snapshot. • Commits • The act of creating a snapshot. • Contains Three pieces of information: • Information about how the files changed from previously. • A reference to the commit that came before it. • Called the “parent commit” • A unique SHA-1 hash code name (40 character string of hex digits)
  4. BASIC GIT TERMINOLOGY • Pulling • The process of downloading

    commits that don’t exist on your machine from a remote repository and merging them to your current branch. • Pushing • The process of publishing your local changes to the remote branch/origin. • Cloning • The act of copying a repository from a remote server. • Head • A reference to the most recent commit. • Working Tree • s
  5. Git workflow visualization Standard Workflow edits git add git add

    git add edits edit s git commit git commit git commit Repo Work Stage Repo Work Stage Repo Work Stage Repo --> time --> git clone git pull Origin git push (git init) internet your pc Origin
  6. GITHUB • GitHub.com is a site for online storage of

    Git repositories. • – You can create a remote repo there and push code to it. • – Many open source projects use it, such as the Linux kernel. • – You can get free space for open source projects, or you can pay for private projects. • Free private repos for educational use: github.com/edu Question: Do I always have to use GitHub to use Git? – Answer: No! You can use Git locally for your own purposes. – Or you or someone else could set up a server to share files. – Or you could share a repo with users on the same file system, as long everyone has the needed file permissions).
  7. LETS DO THE DIRTY HANDWORK • Sign up for a

    GitHub Account. • Set your profile and create your first repository.
  8. LETS DIVE-IN TO GIT EVERYDAY COMMANDS • git init to

    create a new repository. • git log to see what happened. • git checkout and git branch to switch branches. • git add to manage the index file. • git diff and git status to see what you are in the middle of doing. • git commit to advance the current branch. • git reset and git checkout (with pathname parameters) to undo changes. • git merge to merge between local branches. • git tag to mark a known point. Continued..