-1

ALL,

I am trying to revert following operations:

cd <my_proect> && rm mysql-connector-c && git rm mysql-connector-c

at least until I figure out how to update to the current version properly.

Trying to run git reset HEAD mysql-connector-c does not unstage it, because running git status still shows them green and ready to commit

I guess I can try to run git pull to bring that code back and undo the rm command.

But I was wondering if its possible to do without it

TIA!!

Igor
  • 5,620
  • 11
  • 51
  • 103
  • Does this answer your question? [Unstage a deleted file in git](https://stackoverflow.com/questions/9591407/unstage-a-deleted-file-in-git) – hakre Jul 23 '22 at 20:47

1 Answers1

0

You can use git restore

git restore --staged --worktree mysql-connector-c

--staged to restore the index and --worktree to restore the content.

Old way is to use git checkout

git checkout HEAD -- mysql-connector-c/
Ôrel
  • 7,044
  • 3
  • 27
  • 46
  • The "old" way also has the benefit that you can specify the revision of the file and you even must not have had it deleted. Otherwise there is also [`git-reset`](https://git-scm.com/docs/git-reset) and you can do it `--hard`. – hakre Jul 23 '22 at 20:49
  • @hakre you can use `-s ` to select a revision with `git restore` – Ôrel Jul 23 '22 at 20:58
  • @Ôrel: Yes git restore can do _everything_ and its that much better to have an alternative that might be more accessible or at least offers another way of access enhancing the existing repertoire (for me checking out a file feels more straight forward and then it's an argument not parameter and argument, but this is perhaps all only detail). – hakre Jul 23 '22 at 21:00