Open gjost opened 9 months ago
Is the default first branch now called, main
?
Git not prints this when you clone a repository from mits
:
(cmdln) ddr@densho101dev:/var/www/media/ddr$ git clone git@mits.densho.org:ddr-testing-40415.git
Cloning into 'ddr-testing-40415'...
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/git/repositories/ddr-testing-40415.git/
warning: You appear to have cloned an empty repository.
Note that this is what you get if you use Git and not our ddr clone command.
FWIW I ran git config --global init.defaultBranch master
as ddr
and got the same git.exc.GitCommandError
. Looks like maybe something else?
It appears that the master
branch cannot be switched to until you add at least one file and do an initial commit. The ddr2 clone
command fails to do this, resulting in a repo with a git-annex
branch but no master
.
Turns out ddr2 clone
is not used in the normal workflow, so should probably be deprecated.
From research and testing it seems that you cannot switch away from a branch and come back unless there is at least one commit. For example: you clone a repo, the default master
branch is created, and you immediately create and switch to a git-annex
branch, but now you cannot switch back to master
because there is nothing to switch back to.
DDR.commands.clone
does exactly this.
DDR.commands.create
does the same, but it creates collection.json
and others along the way, creating that first commit.
An easy fix would be to make ddr2 clone
use DDR.commands.create
instead of .clone
.
It seems the archivists don't really use ddr2 clone
so this may all be academic.
ddr2 clone
is intended for cloning existing collection repositories -- it says so right in the help!
What we really need is a check on the front end that stops if a collection doesn't exist yet.
Added guardrails to ddr clone
.
ddr-cmdln
commit cfc6e19
: DDR.commands.clone
now checks with Gitolite to see if repository exists on mits
; raises an Exception if it doesn't. This mirrors what DDR.commands.create
already does. DDR.commands.create
is modified so both functions act similarly.
[Revised: For recent problems creating collections using the web UI see #335]
I tried cloning a new collection using
ddr2 clone
and got this: