Giter Site home page Giter Site logo

ejs16's Introduction

Kontrolle mit Hash?

Deep Dive in git!

Neben den Slides meines Vortrags auf der enterJS 2016 sind hier auch die genuzten Befehle der Session nochmal aufgelistet.

Viele der Befehle gehören zu den sogenannten "Plumbing-Commands" die im täglichen Gebrauch weniger gebräuchlich sind. Aber das Verständnis von git erhöhen können.

# start with a simple command
$ mkdir .git

# create the objects directory (all objects stored here)
$ mkdir .git/objects

# refs stores the tag and branches
$ mkdir .git/refs

# create the directory for branch information
$ mkdir .git/refs/heads

# tell git on which the branch the repos is
$ echo "ref: refs/heads/MyMaster"

Ein git status erkennt nun bereits an der erstellten Struktur ein git Repository. Weiter geht es mit dem Befüllen des Repositories.

# create a blob object
$ echo "Hello enterJS!" | git hash-object -w --stdin
9c549bff452686ca42e444962efccdc54c5c54df

# a blob is now written to the object directory, we use the hash of blob to get some information.
# start with the type of object
$ git cat-file -t 9c549bff452686ca42e444962efccdc54c5c54df
blob

# get the size of the object
$ git cat-file -s 9c549bff452686ca42e444962efccdc54c5c54df
15

# get the content of the blob in a 'pretty print' format
$ git cat-file -p 9c549bff452686ca42e444962efccdc54c5c54df
Hello enterJS!

# now assing a filename to the blob via the staging area
$ git update-index --add --cacheinfo 100644 9c549bff452686ca42e444962efccdc54c5c54df readme.txt

# write the tree object with the content of the staging area
$ git write-tree
f4fc37f5c58a930e446f692daa2adabb6c38f8b4

# show the tree object
$ git cat-file -p f4fc37f5c58a930e446f692daa2adabb6c38f8b4
100644 blob 9c549bff452686ca42e444962efccdc54c5c54df    readme.txt

# new create the commit with the reference to the tree object
$ commit-tree f4fc37f5c58a930e446f692daa2adabb6c38f8b4 -m "My first commit"
3a2b89cefb9082732af564435249c6fa613728f9

# now let the branch point to this commit
echo 3a2b89cefb9082732af564435249c6fa613728f9 > .git/refs/heads/MyMaster

ejs16's People

Contributors

mbeelman avatar m-beelman avatar

Stargazers

 avatar Waldemar Reusch avatar Christian Rodriguez Benthake avatar Steffen Zollmann 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.