File deleted in git, need help restoring

Hi, I am working on an app and the file no longer shows in the git pane in R Studio. The file on my local drive is in the same location as always, and it is up-to-date and perfect in every way. Just somehow, it was deleted from my git pane and I can no longer sync it up to github. How would I go about adding it back to that panel so I can start making commits again? See image.


Perhaps you committed the file, that would remove it from that view of the git pane, until it was edited/ saved with a change, at which time it would show again as available for commit in the git pane

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Thanks, @MyKo101 . That was really helpful. I think the hard reset didn't go through quite right but the package helped me get there. Then making a change resulted in everything going right as @nirgrahamuk said. Much appreciate the help!

I agree with what @nirgrahamuk says.

You can use the {git2r} package to perform git actions with a bit more control than the pane gives you, but without having to go down to the Command Line level.

You can use git2r::ls_tree() which will give you a data.frame with all the files in the most recent commit and you can check if your file is in there (search in the columns path and name for your file).

You can also run git2r::status() to see what files are in your git directory that have been modified/created but haven't yet been commited (this is essentially what is in the git pane).

You should also check the .gitignore file in your git directory as the file may have been put in there by accident. If it has, just remove it and it should re-appear