2015. július 3.

Getting started with Git

Git Basics
  • Git thinks of its data more like a set of snapshots of a miniature filesystem
  • if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored
  • you have the entire history of the project right there on your local disk
  • there is very little you can’t do if you’re offline
  • it’s impossible to change the contents of any file or directory without Git knowing about it (Everything in Git is check-summed before it is stored)
  • Git stores everything in its database not by file name but by the hash value (40-character string used for checksumming) of its contents
  • It is hard to get the system to do anything that is not undoable or to make it erase data in any way
  • Git has three main states that your files can reside in: committed, modified, and staged 
    • Committed means that the data is safely stored in your local database
      • your local database is called the "Git Directory" ("Repository"). This is what is copied when you clone a repository from another computer
    • Modified means that you have changed the file but have not committed it to your database yet
      •  this happens in your "Working Directory". The working directory is a single checkout of one version of the project.
    • Staged means that you have marked a modified file in its current version to go into your next commit snapshot 
      • the Staging Area is a file, generally contained in your Git directory, that stores information about what will go into your next commit
  •  The basic Git workflow goes something like this:
    • 1. You modify files in your working directory.
    • 2. You stage the files, adding snapshots of them to your staging area.
    • 3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
Get the latest Git version installed:
  • Add the latest git version to your repository:
    • sudo add-apt-repository ppa:git-core/ppa 
  • Update repository list:
    • sudo apt-get update
  • Install the latest version of git:
    • sudo apt-get install git
  • Check git version:
    • git --version
Essential Git setup after installation
Set up an SSH key to use with GitHub

Get help:
  • there is a general man page and 
  • there are also separate man pages for each command.
  • Check out the Git CheatSheet
  • install GitK for a visual Git history browser

Nincsenek megjegyzések: