Running `git.add` on removed file throws an error
See original GitHub issueI am using the React Native example and have noticed issues with trying to run git.add
to a file that’s been removed. Instead of adding it to the staged
files that’ve been changed, I get a NotFoundError
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:18 (17 by maintainers)
Top Results From Across the Web
Staging Deleted files - git - Stack Overflow
First screenshot clearly shows that 2 files are deleted and not staged, second screenshot shows that when I type git rm "~$Box.SLDASM" ,...
Read more >Recovering Deleted Files in GitHub - Rewind Backups
Learn how to recover deleted git files with the command line, the Github desktop app or web UI, or full backups and restores....
Read more >How to Remove Local Untracked Files in Git Working Directory
We tell Git to track files using the git add and git commit commands. ... A simple git clean command with no options...
Read more >git-checkout Documentation - Git
Prepare to work on top of <commit> , by detaching HEAD at it (see "DETACHED HEAD" section), and updating the index and the...
Read more >Undo possibilities in Git - GitLab Docs
Undo staged local changes · Confirm that the file is staged (that you used git add <file> ) by running git status :...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Some notes for myself, as I continue to debug this:
git add package.json
totally removes it from theindex
filegit reset HEAD package.json
will unstage the deleted file without undeleting that fileindex
fileresetIndex
function inisomorphic-git
remove
function inisomorphic-git
And, sure enough… When I run the relevant commands, they act the way I would “”“expect”“” them to, now understanding the Git implementation a bit better:
So I guess here’s my question: Should this edgecase be handed by
isomorphic-git
or by the clients?The commands are techincally correct in their behavior, but the documentation for these commands infer that they would otherwise handle these edgecases:
As far as I see it, we should either update the documentation for these two commands and add a reference to this particular issue, or we should update the code for these commands and invisibly handle these edgecases. I’d be happy to make a PR to solve this problem and write tests confirming their behavior change if you’d like to go down the “handle edgecase” route. What do you think @wmhilton ?
You can see how I’ve implemented git add in my Git Web Terminal: https://github.com/jcubic/git/blob/gh-pages/js/main.js#L884
The issue with my code is that it doesn’t support
git add .
but it would be easy to add you only need to list all files like (the first branch in 889) but it should use the same code as in else that allow deleting all commands (here there is only delete a single file).