Here is how to reproduce the git problem at least to some extent:
king@klap:~$ mkdir gittest
king@klap:~$ cd gittest
king@klap:~/gittest$ mkdir A
king@klap:~/gittest$ cd A
king@klap:~/gittest/A$ git init
Initialized empty Git repository in /home/king/gittest/A/.git/
king@klap:~/gittest/A$ touch file1
king@klap:~/gittest/A$ git add file1
king@klap:~/gittest/A$ git commit -m "First"
[master (root-commit) 64e0df0] First
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file1
king@klap:~/gittest/A$ git worktree add -b foobar ../B master
Preparing ../B (identifier B)
HEAD is now at 64e0df0 First
king@klap:~/gittest/A$ touch file2
king@klap:~/gittest/A$ git add file 2
fatal: pathspec 'file' did not match any files
king@klap:~/gittest/A$ git add file2
king@klap:~/gittest/A$ git commit -m "Second"
[master abd4169] Second
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file2
king@klap:~/gittest/A$ git branch -d foobar
Deleted branch foobar (was 64e0df0).
king@klap:~/gittest/A$ cd ../B
king@klap:~/gittest/B$ git log
fatal: your current branch 'foobar' does not have any commits yet
king@klap:~/gittest/B$ git status
On branch foobar
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: file1
king@klap:~/gittest/B$ ls
file1
I believe it is a bug that git allowed me the "git branch -d foobar"
operation. If someone knowing where to report a git bug agrees that it
is a bug, please go ahead.
But now comes a surprise:
king@klap:~/gittest/B$ git checkout -b new_foobar master
Switched to a new branch 'new_foobar'
king@klap:~/gittest/B$ git status
On branch new_foobar
nothing to commit, working directory clean
king@klap:~/gittest/B$ ls
file1 file2
That's really a surprise. So, I tried the same in my Sage git repository.
Unfortunately it was not successful:
$ git checkout -b t/28414/p_group_cohomology_in_PY3 t/28414/p_group_cohomology_in_py_3
... <listing all Sage source files> ...
Please, commit your changes or stash them before you can switch branches.
Aborting
I wonder what's different. I am still reluctant to do "git checkout -f
<branchname>", but perhaps that would be my best bet.
Best regards,
Simon