gitless icon indicating copy to clipboard operation
gitless copied to clipboard

"failed to remove" error leads to lost untracked and ignored files?

Open duckdalbe opened this issue 5 years ago • 1 comments

Maybe I'm using gitless wrong, in that case I'd appreciate a pointer! But to my understanding it just deleted my untracked files in a repository.

Here's a reconstructed flow of the commands I used, I hope it makes sense.

> gl status
On branch develop, repo-directory //

Tracked files with modifications:
  ➜ these will be automatically considered for commit
  ➜ use gl untrack f if you don't want to track changes to file f
  ➜ if file f was committed before, use gl checkout f to discard local changes

    tracked-file1


Untracked files:
  ➜ these won't be considered for commit
  ➜ use gl track f if you want to track changes to file f

    untracked-file1
    untracked-file2
> gitless branch -c new-branch
✔ Created new branch new-branch
> gitless switch new-branch
✘ b'warning: failed to remove ignored-file1: Permission denied\nwarning: failed to remove ignored-file2: Permission denied\n…
> gl status
On branch develop, repo-directory //

Tracked files with modifications:
  ➜ these will be automatically considered for commit
  ➜ use gl untrack f if you don't want to track changes to file f
  ➜ if file f was committed before, use gl checkout f to discard local changes

    tracked-file1


Untracked files:
  ➜ these won't be considered for commit
  ➜ use gl track f if you want to track changes to file f

    There are no untracked files to list
> git stash # saving my changes before fixing the problem
> sudo chown …
> gl switch new-branch 
✔ Switched to branch new-branch
> gl status
On branch new-branch, repo-directory //

Tracked files with modifications:
  ➜ these will be automatically considered for commit
  ➜ use gl untrack f if you don't want to track changes to file f
  ➜ if file f was committed before, use gl checkout f to discard local changes

    There are no tracked files with modifications to list


Untracked files:
  ➜ these won't be considered for commit
  ➜ use gl track f if you want to track changes to file f

    There are no untracked files to list
> gl switch develop
✘ b'error: stash@{0}|*|On develop: -- ---gl-develop---|*|\n|*|stash@{2} is not a valid reference\n'
> gl status
On branch develop, repo-directory //

Tracked files with modifications:
  ➜ these will be automatically considered for commit
  ➜ use gl untrack f if you don't want to track changes to file f
  ➜ if file f was committed before, use gl checkout f to discard local changes

    There are no tracked files with modifications to list


Untracked files:
  ➜ these won't be considered for commit
  ➜ use gl track f if you want to track changes to file f

    There are no untracked files to list
> ls "ignored-file*"
ls: cannot access 'ignored*': No such file or directory

After I fixed the file permissions I can switch to new-branch, as you see. But my untracked files and also the ignored file are gone. Is that intended behaviour? Is it due to me using git stash in the middle? None of git's stashes contain my ignored files, though.

I'm not a beginner with git and other VCS, but I didn't find a way to get my untracked and ignored files back — which freaks me out, I have to say. Is there something I'm overlooking or misunderstanding?

duckdalbe avatar Oct 14 '20 13:10 duckdalbe

By reading gitless' code I learned that it uses git stash --all internally, which helped to get my lost data back.

I'm still astonished by gitless' behaviour in this case.

duckdalbe avatar Oct 15 '20 12:10 duckdalbe