Giter Club home page Giter Club logo

git-notes's Introduction

Git Notes

Git can be thought of as a content manager for three trees or three collections of files.

HEAD

Last commit snapshot, next parent.

HEAD is the pointer to the current branch reference - which in turn is a pointer to the last commit made on the current branch.

HEAD may be thought of as a snapshot of the last commit on the current branch.

To see the directory listing and SHA-1 checksums for each file in HEAD:

# Show content or type of HEAD object
git cat-file -p HEAD

# Recursively list the contents of the HEAD tree object
git ls-tree -r HEAD

The Index

The index or staging area is the proposed next commit snapshot.

The index consists of all file contents that were last checked out into the working directory, in the state they were in when last checked out.

When files are replaced with new versions, git commit converts the index into a tree for a new commit. A new commit is created and the branch that HEAD points to is moved to the new commit.

The index is not technically a tree data structure - it is a flattened manifest - but can be thought of as a tree.

Working Directory

The working directory or working tree is a "sandbox" for working on files.

The HEAD and Index store content in the .git directory - efficiently, but inconvenient in terms of access.

The working directory unpacks content into actual files, making them easily accessible for normal editing.

Changes can be tried out in the working directory, before being added to the staging area (index) and thereafter committed to history.

Typical Workflow

  • Checkout a project, or start with a new project
  • Work on files - in the working directory
  • Stage files - git add files to the index
  • Commit files - git commit the contents of index, updating the master/HEAD pointer

git-notes's People

Contributors

csknk avatar

Stargazers

 avatar

Watchers

James Cloos 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.