• Stars
    star
    372
  • Rank 114,858 (Top 3 %)
  • Language
  • Created over 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔧 Learn git-ssb: a decentralized GitHub alternative.

git-ssb-intro

a guide to hacking together on the distributed web

If you're curious about the distributed web, and the prospect of using git collaboratively without a central, closed-source point of origin, you came to the right place!

git-ssb is a great fit for just this. This guide tries to act as a transition aide for GitHub users into the world of git-ssb. It assumes rudimentary knowledge of GitHub. It will walk through:

  1. understanding what "SSB" is.
  2. installing ssb-server -- the SSB peer server -- and joining the network.
  3. installing the git-ssb command and the git-ssb-web web interface.
  4. a walkthrough of using git-ssb to do common GitHub workflows (creating repos, making pull requests, merging pull requests, issues, etc).

git-ssb web activity

A view of recent activity among my friends on git-ssb

What is SSB?

SSB stands for secure scuttlebutt, the database/protocol that powers the peer-to-peer log store scuttlebutt. There is a great deal of information to be found by reading these sites, if you're so inclined.

If you're familiar with bitcoin or blockchains, SSB is akin to having your own personal blockchain: you can append messages of any kind, with any data you'd like. Unlike bitcoin, there's no money involved: it's just a data structure on your local machine.

Your personal log can only be appended to, and is cryptographically secure: each message references the hash of the message that came before it. The whole thing is then also signed by your public key, making it both tamper-proof, and appendable only by the private key holder (you).

The final piece of SSB that makes it all work is the gossip protocol: when you run scuttlebutt, you become a peer in a network of other scuttlebutt users. You can choose to 'follow' other people's personal logs. As a result, whenever you see that user (or any user that follows that user too) online, you can retrieve their latest log entries from them. All without any central server or central authentication.

git-ssb builds on top of this: things like commits, branches, issues, and pull requests are encoded into log entries on each participant's personal log, while the gossip protocol runs in the background and propagates new content to everyone involved in the git repository.

Setup

If you're already up and running on Patchwork (or another client), you can skip to step 3.

1. Install node + npm

You can install node and npm..

  1. from https://nodejs.org, or
  2. using nvm

2. Install an SSB node

Any SSB node should do; there are several implementations. Below we will focus on two of the most popular.

Whichever you choose, make sure you get an invite code from a pub to increase your ability to find other scuttlers.

Desktop GUI: Patchwork

Patchwork is an easy and user-friendly client that's nice to start your SSB experience with, if you're new. Follow the instructions on the main page at https://scuttlebutt.nz

If you're looking for a 'headless'/CLI node to provide SSB services, follow the next section.

Patchwork

Command-Line Interface: ssb-server

The ssb-server is a local secure scuttlebutt server which will manage replicating data with other peers.

3. Install ssb-npm

All of the dependencies for git-ssb and git-ssb itself live on the SSB network. To access them, we'll need to install ssb-npm:

First, install the ssb-npm-registry plugin:

sbot plugins.install npm-registry --from 'http://localhost:8989/blobs/get/&2afFvk14JEObC047kYmBLioDgMfHe2Eg5/gndSjPQ1Q=.sha256'

If this doesn't work (or you aren't following enough people) you can fetch the blob from a centralized source too:

sbot plugins.install npm-registry --from 'http://viewer.scuttlebot.io/&2afFvk14JEObC047kYmBLioDgMfHe2Eg5/gndSjPQ1Q=.sha256'

Restart SSB, then install the ssb-npm command:

npm install -g 'http://localhost:8989/blobs/get/&qcphVNO9k28QT0oASdyjH41XEySuTxX3STooEj+olEE=.sha256'

If you have problems with the above commands you may need to follow different people, so that you can find all the dependencies. cel is a good bet.

4. Install git-ssb

git-ssb is primarily the work of cel, and comes in the form of a command-line program not unlike git or GitHub's hub.

Let's use npm to install git-ssb globally so we can use it in the command-line:

ssb-npm install -g git-ssb --branch %p0H9aCwnOiyFHvFU2o7lFURhOx8VqygW3cS4jlhb66s=.sha256

You can now run git-ssb (or git ssb) from the command line and get a feel for the sorts of things it can do.

NOTE - git-ssb needs an SSB node to work with. You must ensure Patchwork, ssb-server, or simiar is running when executing git-ssb commands.

The git-ssb web interface

If you've already joined the SSB network successfully, you can take a look at what other hackers on SSB are working on! Run git-ssb web and point your web browser at the URL it outputs. (Remember you need to be running ssb-server or Patchwork.)

git-ssb web repo

A repo on git-ssb

You'll see that it's not dissimilar from GitHub: git-ssb-web lets you see commit activity, view repositories, browse commit history, see issues and pull requests. All without a centralized authority.

There are at least a few public git-ssb web servers run by the community, for browsing git-ssb content without running your own ssb-server:

Creating your first SSB git remote

git-ssb makes ssb-server act like a git remote. Navigate to an existing git repository of yours and run

$ git-ssb create ssb my-little-repo

This will create a new git repo on SSB. The command will output something that looks like

Created repo: ssb://%DEvlJYD+zuudMyNWFBjiiNvZ8DbOyBYhCkE5EVtWSV0=.sha256
(my-little-repo)

The string %DEvlJYD+zuudMyNWFBjiiNvZ8DbOyBYhCkE5EVtWSV0=.sha256 is a hash that uniquely identifies your git-ssb repository. To see this in action, you can navigate to (for example) ~/projects and run

$ git clone ssb://%DEvlJYD+zuudMyNWFBjiiNvZ8DbOyBYhCkE5EVtWSV0=.sha256 my-repo

and you'll see that ~/projects/my-repo now exists. git-ssb talked to your local ssb-server server and pulled down the entire git repository.

In fact, you can also view your handiwork by running git-ssb web and opening your browser: you'll see your brand new repo near the top of the activity list and can browse it like you might've on GitHub.

Collaboration: forks and pull requests

If you're reading this article, then you've already found one SSB git repository: this one! Let's create a fork, make some changes, and send a pull request:

Clone

$ git clone ssb://%RPKzL382v2fAia5HuDNHD5kkFdlP7bGvXQApSXqOBwc=.sha256 git-ssb-intro

$ cd git-ssb-intro

Fork

Let's look at the help with git-ssb fork --help:

Usage: git ssb fork [<upstream>] <remote_name>

  Create a new git-ssb repo as a fork of another repo
  and add it as a git remote

Arguments:
  upstream      id, url, or git remote name of the repo to fork.
                default: 'origin' or 'ssb'
  remote_name   Name for the new remote

since we just did a fresh git clone, the remote to the original repo is origin; you can type git remote -v and have a look. since origin (or ssb) are the default for forks, you can omit this option.

remote_name is whatever you'd like to call the remote of your fork. I usually call mine noffle-ssb, to indicate that it's a fork remote and that it's my personal one:

$ git-ssb fork noffle-ssb
Created repo: ssb://%DKWLuN05qtwjdwTG7zCG4aU12muBK2pkpYgaBbeVkTM=.sha256 (git-ssb-intro)
Added remote: noffle-ssb

Great! Now we can make some changes and commit them. I forgot to add a license to this document, so we can add that, commit, and push:

$ cat >> README.md

# license

ISC
^D

$ git commit -am 'adds license'
[master 3a7c5f7] adds license
 1 file changed, 4 insertions(+)

$ git push noffle-ssb
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 2.55 KiB | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
Decoding objects: 100% (3/3)
Pushing blobs...pwMeF/zIvuwFc4/T3VBwpHr+r6H+dHvWKFyIxCs1+08=.sha256
Published %i0Fcr3zRdf50Tin1UdEmYU38eKWthmkO3XgpfMYU1AU=.sha256ha256
To ssb://%DKWLuN05qtwjdwTG7zCG4aU12muBK2pkpYgaBbeVkTM=.sha256
   6a701c2..3a7c5f7  master -> master

We can see our fork on the web interface, too! navigate to http://localhost:7718 and you'll see your repo fork.

Let's finally create a pull request with our changes:

$ git-ssb pull-request

this will launch your text editor and let you type in a message. It's good practice to make the first line of your message the subject, and leave two newlines before writing your message. something like

test pull request

please merge me

Sure enough, you can now navigate to the from-github-to-git-ssb repo on SSB and see your pull request: http://localhost:7718/%25RPKzL382v2fAia5HuDNHD5kkFdlP7bGvXQApSXqOBwc%3D.sha256/pulls

If you were the owner of the git repo, you could merge this pull request from the command line by pulling down the fork remote and merging:

git fetch ssb://%RPKzL382v2fAia5HuDNHD5kkFdlP7bGvXQApSXqOBwc=.sha256 noffle-ssb:noffle-ssb
git merge noffle-ssb
git push ssb

Alternative: collaboration without forks

git-ssb's permissionless model has an interesting consequence: anybody can push to anybody else's git repository. Coming from a GitHub background this probably sounds like madness, but folks on SSB have been using this model with good success. A pull request might look like this:

$ git clone ssb://%RPKzL382v2fAia5HuDNHD5kkFdlP7bGvXQApSXqOBwc=.sha256 foobar

$ git checkout -b @noffle/master

$ cd foobar

$ vim index.js
(edit edit edit)

$ git commit -am 'wark'

$ git push ssb

$ git ssb pull-request

The nomenclature is to treat the ssb remote as the "true" remote, and work off of a branch called @your-username/master as your own master, emulating a forked repo. This seems to work well: the SSB network thrives off of being a group of kind, respectful folks who don't push to each other's master branch. :)

Push conflicts

Since git-ssb allows users to push to the same remote asynchronously, there is a possibility that they will conflict. This is different from a git merge conflict: in this case, there are two (or more) competing HEADs for e.g. master.

If this happens, git-ssb will consider the branch as being in a conflict state. It will automatically add a new "conflict branch" for each conflicting HEAD. The name of each conflict branch will be prefixed by its SSB message ID. To resolve the conflict, one should merge the conflict branches locally as appropriate, and then push the new head and delete the conflict branches. e.g.:

git checkout master
git fetch origin
git merge origin/%msg1/master [origin/%msg2/master...]
# resolve merge conflict
...
git push origin master -d %msg1/master [-d %msg2/master...]

Go forth and collaborate!

Well done, and welcome to the scuttleverse and the world of distributed social coding! share git-ssb with your friends, and consider managing an SSB remote of your GitHub work, to encourage further growth of the distributed web.

Thanks for reading! please share feedback or questions as issues on this repo, or, if you find any errors in the text, send a pull request.

Contributors

  • @noffle: wrote this doc
  • @cel: answered my many questions, and wrote most of the section on "push conflicts"
  • @mixmix: several clarifications and improvements

License

CC0

More Repositories

1

art-of-readme

💌 Things I've learned about writing good READMEs.
7,030
star
2

common-readme

🌟 « a common readme for node »
JavaScript
378
star
3

hypergit

Manage and clone peer-to-peer git repositories.
JavaScript
205
star
4

hyperpad

🎍 A peer-to-peer collaborative text editor for people and their communities.
JavaScript
196
star
5

electron-speech

🎤 Easy speech recognition in Node!
JavaScript
170
star
6

wisdom

📜 My little collection of personal wisdom.
132
star
7

p2p-handbook

🐴 Let's learn how to peer-to-peer!
129
star
8

peer-npm

🐝 Publish and install node packages from the swarm.
JavaScript
117
star
9

web-udp

Experiment for a web standard for creating and using UDP sockets in the browser
79
star
10

airpipe

Create a stdin/stdout pipe easily over wifi or internet.
JavaScript
79
star
11

p2p-faq

❓ Commonly asked questions about peer-to-peer networks & programs.
60
star
12

nano-ecs

🔹 A nano-sized Entity-Component-System library.
JavaScript
59
star
13

ipfs-hyperlog

🔗 IPFS Merkle DAG that replicates based on append-only logs and causal linking.
JavaScript
58
star
14

gitverse

local offline p2p social git frontend
JavaScript
56
star
15

ice-box

❄️ Create immutable directory pipelines.
JavaScript
52
star
16

ipfs-blog

🌐 Host a blog ..without the hosting!
JavaScript
47
star
17

hyperpad-desktop

🎍 A peer-to-peer collaborative text editor for people and their communities.
CSS
45
star
18

airfile

📤 Painlessly transfer files from a web browser to your local machine
JavaScript
44
star
19

friendpm

👭 Share, publish, and install node packages from your cache over the local network.
JavaScript
42
star
20

secure-gossip

📞 Secure, transport agnostic, message gossip protocol.
JavaScript
40
star
21

ssb-npm-101

Installing & using npm with secure scuttlebutt.
38
star
22

hyper-string

conflict-free p2p string data structure powered by a hyperlog of operations
JavaScript
38
star
23

pubsub-swarm

🐝 Form a p2p swarm of nodes around a topic and exchange messages.
JavaScript
34
star
24

sailing-patchfoo

Sail the high seas of scuttlebutt with Patchfoo! ⛵
34
star
25

txt-blit

Draw lines of text onto other lines of text. Cooler than it sounds.
JavaScript
28
star
26

hyperdb-index

Build a realtime index over a hyperdb.
JavaScript
28
star
27

voicetube

🎵 Voice controlled YouTube music player in the browser, ideal for hands-free environments.
JavaScript
25
star
28

recs

🔔 functional entity-component-system experiment
JavaScript
23
star
29

ssb-webify

publish a local directory into a scuttlebutt website
JavaScript
22
star
30

kappa-chat

p2p anarchist real-time communication protocol using append-only logs
JavaScript
22
star
31

screen-stream

📹 Get a video stream of your computer's display.
JavaScript
22
star
32

mic-stream

[UNMAINTAINED] 🎤 Get a stream of audio data from the microphone on the browser or with Node!
JavaScript
22
star
33

noffle-business-card

JavaScript
21
star
34

exrot

📷 Snap webcam photos from the command line.
JavaScript
21
star
35

ipcat

🐈 Retrieve IPFS object data and send it to stdout.
Go
19
star
36

textarea-op-stream

readable stream of a textarea's inserts and deletes
JavaScript
18
star
37

hyper-textarea

Back a textarea with a hyper-string for conflict-free p2p replication!
JavaScript
18
star
38

binary-fsk

encode & decode binary frequency-shift keyed signals to/from data
JavaScript
18
star
39

github-dependency-crawl

🪲 Crawl GitHub issues to build a dependency graph
JavaScript
18
star
40

hypercore-private-box

Encrypt messages that only members from a set of hypercores can decrypt.
JavaScript
16
star
41

phaser-capture

Phaser (http://www.phaser.io) plugin for easily capturing screenshots (PNG, JPEG) and videos (GIF, WebM).
JavaScript
16
star
42

tdag

Plaintext task management for graph nerds.
JavaScript
15
star
43

git-remote-hypergit

git remote for hypergit
JavaScript
15
star
44

docstrings

Interpret a string literal at the beginning of a function as its documentation.
JavaScript
15
star
45

ssb-exchange

Fully sync two secure-scuttlebutt databases over a duplex stream.
JavaScript
15
star
46

latest-tweets

🐦 Get a JSON array of a Twitter user's latest tweets -- no Twitter API required!
JavaScript
15
star
47

hyperdb-git-repo

p2p git repo primitive
JavaScript
14
star
48

dotfiles

🔩 Most of my *nix-y configuration files.
Vim Script
13
star
49

picast

📺 Play media from your computer on a Raspberry Pi.
JavaScript
13
star
50

twitter-kv

🐦 Key-value store over twitter user feeds
JavaScript
13
star
51

agenda-cli

📆 Keep track of things in the future.
JavaScript
12
star
52

bisecting-between

🔪 Produces a unique value that sorts between two other given values.
JavaScript
11
star
53

internet-of-buckets

http wrapper for controlling The Internet of Buckets art installation
JavaScript
11
star
54

osm-tty

Interactive offline OpenStreetMap viewer in the terminal.
JavaScript
11
star
55

raycast-2d-tilemap

🔳 Test a ray for intersections against a 2D tile map.
JavaScript
11
star
56

grid-point-store

Fast 2D point insertions and spatial querying over grid of fixed size cells.
JavaScript
11
star
57

hyperdb-git

JavaScript
10
star
58

goertzel

🎤 Fast frequency detection using the Goertzel algorithm.
JavaScript
10
star
59

hpad

📄 Peer-to-peer documents from the command line.
JavaScript
9
star
60

hyperswarm

🐜 Create a p2p webrtc swarm around a hyperlog.
JavaScript
9
star
61

danceparty

👯 👯 👯 👯 👯 👯 👯 👯
JavaScript
9
star
62

rotating_8bit_wallpapers

A little script that sets up rotating wallpapers on your desktop based on the time of day. Hooray!
Shell
9
star
63

mapbox-style-downloader

JavaScript
8
star
64

twitter-rss-noauth

🐦 Retrieves a Twitter timeline and outputs an RSS feed -- without the Twitter API!
JavaScript
8
star
65

p2p-db

An open-ended peer-to-peer database.
JavaScript
8
star
66

hypercore-progress

Track upload/download progress of a hypercore replication stream.
JavaScript
7
star
67

collide-2d-aabb-aabb

💥 Determines whether a moving axis-aligned bounding box (AABB) collides with other AABBs.
JavaScript
7
star
68

tile-dl

JavaScript
7
star
69

ssb-web-resolver

JavaScript
7
star
70

goertzel-stream

🎵 Detects the presence of a single frequency in a stream of signal samples.
JavaScript
7
star
71

argv-or-stdin

use the 1st argument, or, if none is present, standard input
JavaScript
7
star
72

gdx-immediate-gui

🎮 Immediate-style GUI for Java and libgdx, inspired by imgui.
Java
7
star
73

geohash-point-store

🌏 Store and query spatial points using geohashes and LevelDB.
JavaScript
6
star
74

chacha-stream

Encryption and decryption streams of libsodium's chacha20 implementation.
JavaScript
6
star
75

hyperlog-reduce

Implement an async reduce function over a hyperlog.
JavaScript
6
star
76

collide-2d-aabb-tilemap

💥 Collision handling for bounding boxes and a tile map.
JavaScript
6
star
77

hyperlog-doctor

💊 cli tool for checking and repairing hyperlogs
JavaScript
6
star
78

handshake-stream

wrap a duplex stream in a two-way handshake
JavaScript
6
star
79

fallback-ipfs-shell

Provides access to either a running or new IPFS node, in that order of preference.
Go
6
star
80

web-ready

CLI to not exit until a button is pressed on a local website.
JavaScript
5
star
81

pi-voice-command-google

Recognize a single voice command on a Raspberry Pi using the Google Speech API.
JavaScript
5
star
82

sort-subset

sort a subset of an array in-place
JavaScript
5
star
83

ipfs-twitter-resolver

resolve /twitter/user/key to an IPFS address
JavaScript
5
star
84

behaviortree-sexp

A S-expression parser for behaviour trees.
JavaScript
5
star
85

p2p-file-store

Filesystem-based blob store that syncs to other fs-based blob stores.
JavaScript
5
star
86

geo-cli

🌍 Output your device's current longitude/latitude geolocation to stdout.
JavaScript
4
star
87

strapdown-cli

✨ Produce pretty web pages from markdown.
JavaScript
4
star
88

parallel

(Go) ⏩ Run many functions in parallel, but fast-bail on errors.
Go
4
star
89

abstract-point-store

Test suite & interface to implement a geographic point storage backend.
JavaScript
4
star
90

talks

🎤 Talks that I've given.
HTML
4
star
91

patchfoo

github mirror of patchfoo (from git-ssb). maybe not quite so up-to-date
JavaScript
4
star
92

bisecting-numbers

✂️ Integer-like number system where any number can be bisected to form infinite integer subsystems.
JavaScript
4
star
93

ssb-clientkit

TypeScript
4
star
94

CHAIN_SWORD

JavaScript
4
star
95

tone-cli

Generate a tone from the command line.
JavaScript
4
star
96

geo-legacy

📦 🌍 Get the geo-coordinates of every package at every version an author has published.
JavaScript
4
star
97

field-trip

🚩 Walk an unknown directed graph async
JavaScript
4
star
98

merkle-treehouse

experiment
3
star
99

mapeo-protocol

JavaScript
3
star
100

append-only-log

🚋 🚋 🚋 Test suite & interface for append-only log modules.
JavaScript
3
star