think tank forum

technology » git annex

lucas's avatar
8 years ago
link
lucas
i ❤ demo
bluet,

i'm having the damnedest time getting this to work. i'm excited to get running with it, but i can't manage to get anything synced between any of my devices (laptop, web server, android, anything). hrmph.
lucas's avatar
8 years ago
link
lucas
i ❤ demo
at least i got gitweb working over https.

now my web server provides SVN, Hg, and Git. it's pretty obscene.
bluet's avatar
8 years ago
link
bluet
Are you using the Assistant/webapp?

Are you following the walkthrough? https://git-annex.branchable.com/walkthrough/

You might want to play around with syncing locally, on a single device with clones in different directories. Then syncing Unix <---> Unix should be easy. I've never tried using it with Windows or Android.
lucas's avatar
8 years ago
link
lucas
i ❤ demo
i can't even get git to work in general.

for example, on my laptop, i do the following:

lucas@calliope MINGW32 /e/testenv
$ git clone https://www.wingedleopard.net/git/websites/th … forum/.git 
Cloning into 'thinktankforum'...
remote: Counting objects: 1377, done.
remote: Compressing objects: 100% (421/421), done.
remote: Total 1377 (delta 975), reused 1344 (delta 954)
Receiving objects: 100% (1377/1377), 351.44 KiB | 459.00 KiB/s, done.
Resolving deltas: 100% (975/975), done.
Checking connectivity... done.

lucas@calliope MINGW32 /e/testenv
$ cd thinktankforum/

lucas@calliope MINGW32 /e/testenv/thinktankforum (master)
$ vim register.php

lucas@calliope MINGW32 /e/testenv/thinktankforum (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   register.php

no changes added to commit (use "git add" and/or "git commit -a")

lucas@calliope MINGW32 /e/testenv/thinktankforum (master)
$ git add .

lucas@calliope MINGW32 /e/testenv/thinktankforum (master)
$ git commit -m "WTF GIT"
[master 011af82] WTF GIT
 1 file changed, 1 insertion(+)

lucas@calliope MINGW32 /e/testenv/thinktankforum (master)
$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 306 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To https://www.wingedleopard.net/git/websites/th … forum/.git 
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'https://www.wingedleopard.net/git/websites/thinktankforum/.git'


am i using git all wrong?
bluet's avatar
8 years ago
r3, link
bluet
You can get around this by having a bare repository on your server:

~ $ mkdir server
~ $ cd server
~/server $ git init --bare
Initialized empty Git repository in /home/mastensg/server/
~/server $ cd ..
~ $ git clone server laptop
Cloning into 'laptop'...
warning: You appear to have cloned an empty repository.
done.
~ $ cd laptop
~/laptop $ echo a > file
~/laptop $ git add file
~/laptop $ git commit -m "add file"
[master (root-commit) f47d34b] add file
 1 file changed, 1 insertion(+)
 create mode 100644 file
~/laptop $ git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 215 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /home/mastensg/server
 * [new branch]      master -> master
~/laptop $ cd ../server
~/server $ git log --oneline
f47d34b (HEAD, master) add file
~/server $


Or, if the repository on your server is a clone of something else:

git clone --bare ...


... Or, if you want to work directly with the files on your server, but still be able to push there from your laptop; do this on your laptop:

git config --global push.default matching


I keep bare repositories on my servers. That way, they behave just like GitHub. If I want to edit the files on the server, I clone into another directory on that server, and then push and pull locally.
lucas's avatar
8 years ago
r2, link
lucas
i ❤ demo
So bare means that it doesn't have a working directory?

That worked for me. Thank you. And that makes sense to keep bare repositories on the server.

So when a repository is named ``repo.git'', that means it's a bare repository, huh? And ``repo'' would be the name of a clone with a working directory, right?

This explains an oddity in my Apache git/gitweb configuration. gitweb was showing projects like:
websites/thinktankforum/.git

But I didn't understand why there was the trailing .git. Now I understand that gitweb was looking for the actual git repo, not the clone of the working directory. Right?

Then it seems to me that github, for example, uses this naming convention:
https://github.com/foreverlarz/thinktankforums -- gitweb-esque interface
https://github.com/foreverlarz/thinktankforums.git -- git repository itself

Is that accurate? Then, if I wanted to replicate that behavior on my server, I'd use this Apache config:
<VirtualHost 10.0.0.1:443>

    ServerName www.mydomain.com 

    RewriteEngine On
    RewriteCond %{HTTP_HOST}    !^www\.mydomain\.com [NC]
    RewriteRule ^/?(.*)         https://www.mydomain.com/ $1 [L,R=301]

    SSLEngine on
    SSLOptions +StrictRequire
    SSLCertificateFile /home/user/web/ssl/mydomain-com.crt
    SSLCertificateKeyFile /home/user/web/ssl/mydomain-com.key
    SSLCACertificateFile /home/user/web/ssl/rapidssl.crt

    DocumentRoot /home/user/web/mydomain-com

    <Directory /home/user/web/mydomain-com>
        Options All
        AllowOverride All
        Require all granted
    </Directory>

    CustomLog /home/user/web/log/access_mydomain-com.log combined
    ErrorLog /home/user/web/log/error_mydomain-com.log

    ScriptAliasMatch \
        "(?x)^/git/(.*/(HEAD | \
                        info/refs | \
                        objects/(info/[^/]+ | \
                                 [0-9a-f]{2}/[0-9a-f]{38} | \
                                 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                        git-(upload|receive)-pack))$" \
        /usr/lib/git-core/git-http-backend/$1
    <Directory /usr/lib/git-core>
        SetEnv GIT_PROJECT_ROOT /home/user/git
        SetEnv GIT_HTTP_EXPORT_ALL
        Options +ExecCGI
        SSLRequireSSL
        AuthType Basic
        AuthName "private"
        AuthUserFile /home/user/web/passwd
        Require valid-user
    </Directory>
    Alias /git/ /usr/share/gitweb/
    <Directory /usr/share/gitweb>
        SetEnv GITWEB_CONFIG    /home/user/git/gitweb.conf
        SetEnv GIT_PROJECT_ROOT /home/user/git
        AddHandler cgi-script .cgi
        DirectoryIndex gitweb.cgi
        Options +ExecCGI
        SSLRequireSSL
        AuthType Basic
        AuthName "private"
        AuthUserFile /home/user/web/passwd
        Require valid-user
    </Directory>

    WSGIScriptAlias /hg /home/user/hg/hgweb.wsgi
    <Directory /home/user/hg>
        AddHandler wsgi-script .wsgi
        Options +ExecCGI
        SSLRequireSSL
        AuthType Basic
        AuthName "private"
        AuthUserFile /home/user/web/passwd
        Require valid-user
    </Directory>

    Alias /pma /home/user/web/pma
    <Directory /home/user/web/pma>
        SSLRequireSSL
        Require all granted
    </Directory>

    <Location /svn>
        DAV svn
        SVNParentPath /home/user/svn
        SVNListParentPath On
        SSLRequireSSL
        AuthType Basic
        AuthName "private"
        AuthUserFile /home/user/web/passwd
        Require valid-user
    </Location>

</VirtualHost>


Which seems to be working!

All of those paths are the default install locations for the packages on Debian. And yes, I'm a weirdo, using my home directory for all of my web stuffs.
bluet's avatar
8 years ago
link
bluet
If it works, it's fine. :)

I don't really use this git web stuff myself, only git over SSH, tig and gitk for more or less graphical interfaces, and myrepos to keep track of collections of repositories.

Oh, and I might've used git instaweb once or twice.
lucas's avatar
8 years ago
link
lucas
i ❤ demo
i really like being able to access my repositories from any computer. like if i'm teaching, i can access my materials from the web.

now i'm trying to get access to annexed files through gitweb...
lucas's avatar
8 years ago
link
lucas
i ❤ demo
$ sudo pkg install hs-git-annex
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 211 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:

    ...


The process will require 2 GiB more space.
193 MiB to be downloaded.

Proceed with this action? [y/N]:


good lord.
nny's avatar
8 years ago
link
nny
M̮͈̣̙̰̝̃̿̎̍ͬa͉̭̥͓ț̘ͯ̈́t̬̻͖̰̞͎ͤ̇ ̈̚J̹͎̿̾ȏ̞̫͈y̭̺ͭc̦̹̟̦̭̫͊̿ͩeͥ̌̾̓ͨ
ya'll cray
lucas's avatar
8 years ago
link
lucas
i ❤ demo
i struggle with all this git stuff.

i hate my digital life anymore.
Carpetsmoker's avatar
8 years ago
r1, link
Carpetsmoker
Martin
> The process will require 2 GiB more space.

That's probably because it requires ghc (the Haskell compiler), which is indeed rather big.

> i struggle with all this git stuff.

It's an overcomplicated piece of shit. Sure, it's pretty well thought out technically, but the user interface is abysmal, as are the docs. The only reason it's as popular as it is is because of its original author (Torvaldus) and GitHub (who had to compete against sourceforge. Hard job there).

https://git-man-page-generator.lokaltog.net/
lucas's avatar
8 years ago
link
lucas
i ❤ demo
Haha. Yep, that git man page generator is just like the rest of the git man pages, as far as I'm concerned.
Carpetsmoker's avatar
8 years ago
link
Carpetsmoker
Martin
Compare:

[~]% git help commit | wc -l
498

[~]% hg help commit | wc -l
59

This pretty much sums up why hg > git.
lucas's avatar
8 years ago
link
lucas
i ❤ demo
that's pretty amazing.

also don't know why i didn't see this post when i visited ttf a month ago.

but few use hg anymore, right? git's experiencing a huge boon...
Carpetsmoker's avatar
8 years ago
link
Carpetsmoker
Martin
> but few use hg anymore, right? git's experiencing a huge boon...

Yeah, hg seems to be dying, which is a real shame if you ask me. I actually migrated all my stuff to git/GitHub a while ago: https://arp242.net/weblog/i-dont-like-git-but … to-it.html
lucas's avatar
7 years ago
link
lucas
i ❤ demo
yeah, that's why i switched to git. it's so confusing to me, though.
lucas's avatar
7 years ago
link
lucas
i ❤ demo
i want to revisit this someday. it seems great in theory. just difficult for me in practice.

all the special remote types are great!

bluet, still using git-annex? any news?
bluet's avatar
7 years ago
link
bluet
i use git-annex every day. it's my primary way of moving files around. no news, it just works
lucas's avatar
7 years ago
link
lucas
i ❤ demo
no news is good news, then :)

i'm looking to get it working with fastmail.com's file service, thanks to its support for webdav as a special remote with chunking. i'm trying to write up my projects consistently, so i might come back for help or to share my experience.

i'm using fastmail and love it. i get mail, caldav, carddav, and file space (webdav/ftp).

my android phone uses imap with push, caldav sync, carddav sync, and syncs photos. but because they only have webdav/ftp support, good incremental backups are difficult to automate.

i think that git-annex and the assistant is the perfect solution for incremental backups of organized files to webdav.
lucas's avatar
7 years ago
link
lucas
i ❤ demo
does anyone here use git-annex and git-crypt together, maybe even in conjunction with 'git-annex encryption'http://git-annex.branchable.com/encryption/ ?!
bluet's avatar
7 years ago
link
bluet
i moved to fastmail last year myself :D

i only use it for email on my own domain
bluet's avatar
7 years ago
link
bluet
i briefly looked at git-crypt, but gave up on it

i keep my secrets in a keepassx file in my git-annex repository

i only keep my repositories on my own machines (with full disk encryption by dm-crypt) and rsync.net

sometimes i worry about rsync.net spying on me, but i've learned to live with it... :/
lucas's avatar
7 years ago
link
lucas
i ❤ demo
> i moved to fastmail last year myself :D

cool! i really like that they offer custom DNS.
Carpetsmoker's avatar
7 years ago
link
Carpetsmoker
Martin
I've been at FastMail since 2012 or 2013. By far the best email solution I could find.
lucas's avatar
7 years ago
link
lucas
i ❤ demo
starting over, trying to follow the git annex walkthrough. i do exactly what it says, but get an error.

lucas@calliope MINGW32 /e/demo
$ git init
Initialized empty Git repository in E:/demo/.git/

lucas@calliope MINGW32 /e/demo (master)
$ git annex init
init
  Detected a filesystem without fifo support.

  Disabling ssh connection caching.

  Detected a crippled filesystem.

  Enabling direct mode.
ok
(recording state in git...)

lucas@calliope MINGW32 /e/demo (annex/direct/master)
$ git annex add .
add tails-i386-2.12.iso ok
(recording state in git...)

lucas@calliope MINGW32 /e/demo (annex/direct/master)
$ git commit -a -m addedstuff
fatal: This operation must be run in a work tree


damn this bare/working distinction!
lucas's avatar
7 years ago
r2, link
lucas
i ❤ demo
why does `git annex init` seem to ruin the working tree?

example i
lucas@calliope MINGW32 /e
$ mkdir demo2

lucas@calliope MINGW32 /e
$ cd demo2

lucas@calliope MINGW32 /e/demo2
$ git init
Initialized empty Git repository in E:/demo2/.git/

lucas@calliope MINGW32 /e/demo2 (master)
$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)

lucas@calliope MINGW32 /e/demo2 (master)
$ git annex init
init
  Detected a filesystem without fifo support.

  Disabling ssh connection caching.

  Detected a crippled filesystem.

  Enabling direct mode.
ok
(recording state in git...)

lucas@calliope MINGW32 /e/demo2 (annex/direct/master)
$ git status
fatal: This operation must be run in a work tree

lucas@calliope MINGW32 /e/demo2 (annex/direct/master)
$


example ii
lucas@calliope MINGW32 /e
$ mkdir demo3

lucas@calliope MINGW32 /e
$ cd demo3

lucas@calliope MINGW32 /e/demo3
$ git init
Initialized empty Git repository in E:/demo3/.git/

lucas@calliope MINGW32 /e/demo3 (master)
$ echo hello > myfile

lucas@calliope MINGW32 /e/demo3 (master)
$ git add myfile
warning: LF will be replaced by CRLF in myfile.
The file will have its original line endings in your working directory.

lucas@calliope MINGW32 /e/demo3 (master)
$ git commit -m "a new hello."
[master (root-commit) 714edff] a new hello.
warning: LF will be replaced by CRLF in myfile.
The file will have its original line endings in your working directory.
 1 file changed, 1 insertion(+)
 create mode 100644 myfile

lucas@calliope MINGW32 /e/demo3 (master)
$ git annex init
init
  Detected a filesystem without fifo support.

  Disabling ssh connection caching.

  Detected a crippled filesystem.

  Enabling direct mode.
ok
(recording state in git...)

lucas@calliope MINGW32 /e/demo3 (annex/direct/master)
$ echo "byebye" > myfile2

lucas@calliope MINGW32 /e/demo3 (annex/direct/master)
$ git add myfile2
fatal: This operation must be run in a work tree

lucas@calliope MINGW32 /e/demo3 (annex/direct/master)
$
lucas's avatar
7 years ago
link
lucas
i ❤ demo
the answer is in the direct mode doc.

Windows always uses direct mode.



what doesn't work in direct mode

A very few git-annex commands don't work in direct mode, and will refuse to do anything. For example, git annex unlock doesn't make sense in direct mode.

As for git commands, direct mode prevents using any git command that would modify or access the work tree. So you cannot git commit or git pull (use git annex sync for both instead), or run git status (use git annex status instead). These git commands will complain "fatal: This operation must be run in a work tree".

The reason for this is that git doesn't understand how git-annex uses the work tree in direct mode. Where git expects the symlinks that get checked into git to be checked out in the work tree, direct mode instead replaces them with the actual content of files, as managed by git-annex.

There are still lots of git commands you can use in direct mode. For example, you can run git log on files, run git push, git fetch, git config, git remote add etc.