Giter Site home page Giter Site logo

gitlet's Introduction

Gitlet

Git implemented in JavaScript.

Over the last six years, I've become better at using Git for version control. But my conceptions of the index, the working copy, the object graph and remotes have just grown fuzzier.

Sometimes, I can only understand something by implementing it. So, I wrote Gitlet, my own version of Git. I pored over tutorials. I read articles about internals. I tried to understand how API commands work by reading the docs, then gave up and ran hundreds of experiments on repositories and rummaged throught the .git directory to figure out the results.

I discovered that, if approached from the inside out, Git is easy to understand. It is the product of simple ideas that, when combined, produce something very deep and beautiful.

Using Gitlet to understand Git

If you would like to understand what happens when you run the basic Git commands, you can read Git in six hundred words.

Afterwards, read the heavily annotated Gitlet source. 1000 lines of code sounds intimidating. But it's OK. The annotations explain both Git and the code in great detail. The code mirrors the terminology of the Git command line interface, so it should be approachable. And the implementation of the main Git commands is just 350 lines.

I wrote an article, Introducing Gitlet, about the process of writing the code.

Getting the code

Clone it from GitHub

$ git clone [email protected]:maryrosecook/gitlet.git

Or install it from npm.

$ npm install -g gitlet

Using Gitlet for version control

I wrote Gitlet to explain how Git works. It would be unwise to use Gitlet to version control your projects. But it does work. Sort of.

First, install Node.js. Then:

    $ npm install -g gitlet

    $ mkdir a
    $ cd a
./a $ gitlet init

./a $ echo first > number.txt
./a $ gitlet add number.txt
./a $ gitlet commit -m "first"
      [master 2912d7a2] first

./a $ cd ..
    $ gitlet clone a b

    $ cd b
./b $ echo second > number.txt
./b $ gitlet add number.txt
./b $ gitlet commit -m "second"
      [master 484de172] second

    $ cd ../a
./a $ gitlet remote add b ../b
./a $ gitlet fetch b master
      From ../b
      Count 6
      master -> b/master
./a $ gitlet merge FETCH_HEAD
      Fast-forward

./a $ gitlet branch other
./a $ gitlet checkout other
      Switched to branch other

./a $ echo third > number.txt
./a $ gitlet add number.txt
./a $ gitlet commit -m "third"
      [other 656b332d] third

./a $ gitlet push b other
      To ../b
      Count 9
      other -> other

Running the tests

Install Node.js.

$ git clone [email protected]:maryrosecook/gitlet.git
$ cd gitlet
$ npm install
$ npm test

Contact

Mary Rose Cook - http://maryrosecook.com
I made this while working at the Recurse Center.

gitlet's People

Contributors

amio avatar brandly avatar coderaiser avatar darius avatar maryrosecook avatar peterwhittaker avatar pietromenna avatar suyash avatar tracker1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitlet's Issues

This Is Amazing!

I just wanna say that this is one of the coolest things I've ever seen! Well Done!!!

Compare to dugite?

https://github.com/desktop/dugite is a git binding that used in GithubDesktop, will this be a JS replacement for dugite?

Does gitlet support all features that GithubDesktop or other git client GUI needs?

PS I'm creating a Git GUI, and is looking at gitlet and dugite.

HTTPS on Docs Site?

Hi there, first of all, thanks so much for Gitlet! Really cool that this exists! ๐Ÿ™Œ

I was wondering if you would be open to adding HTTPS / TLS to the docs site. Right now there is only HTTP available: http://gitlet.maryrosecook.com/

Attempting to access https://gitlet.maryrosecook.com/ leads to a NET::ERR_CERT_COMMON_NAME_INVALID error:

This server could not prove that it is gitlet.maryrosecook.com; its security certificate is from maryrosecook.com.

Command "clone" results in an error on a Windows7 machine...

Hi, command E:\Work\gitlet clone a b resulted in error message...

Error: cannot lock the ref refs/remotes/origin\master

And few changes made the command work...

  // **toRemoteRef()** converts `remote` and branch name `name` into a
  // qualified remote branch ref.
  toRemoteRef: function(remote, name) {
    if (process.platform == "win32") {      
      return "refs/remotes/" + remote + "/" + name;
    } else {
      return  "refs/remotes/" + remote + nodePath.sep + name;
    }    
  },


Support npm

With npm support, gitlet could be used for NodeOS. The following features are missing from gitlet which prevent it from being used with npm, and as an extension NodeOS:

  • #8 Implement git config --get remote.<remote>.url

Collaborators, please feel free to update this list as you see fit!

Question: Is the post "Git in six hundred words" independent from any Git implementation?

Hi, I like the short post Git in six hundred words and would like to recommend it to few git beginners.

What is of high importance for me though is the fact, whether the whole content is valid for the official Git implementation or whether there are some deviations specific to the Gitlet implementation. If there are any, could you point out the parts of the article which are not valid for the official Git client?

A question about Github implementation

Hi,
I have a question and I don't know where to ask. I am going to make a website exactly like GitHub but It will be decentralized (Implement it using Blockchain). But I don't know how to link between the local .git directory to a website? And do you know any library,npm package, tool...etc that implement all git functions? (And I could use it in a project for implementing Github)

Why the .gitlet directory?

Reading your docs I've seen [you are using a non-standard .gitlet directory](If the repository is not bare, put the directories inside the .gitlet directory) instead of the standard .git one. Why is this? There could be some compatibilities issues? I'm asking this because we are thinking we could use gitlet at NodeOS... :-)

Tests has a lot fails.

When I install jasmine-node and run npm test I have a lot fails.

Finished in 3.118 seconds
285 tests, 603 assertions, 316 failures, 0 skipped

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.