1

I tried the same on my terminal (on linux ubuntu) following this video (timestamp 1:02:34)

https://www.youtube.com/watch?v=8JJ101D3knE&t=2488s

This is what it looks like on my terminal screen

I don't understand what's wrong because even my git version is the latest one I could download

Please help me out.

1
  • 1
    git restore was introduced in Git v2.23.0. You're on v2.7.4, which is 16 minor versions behind. The latest release is v2.31.0
    – NullDev
    Commented Mar 18, 2021 at 15:01

2 Answers 2

1

git restore was introduced in Git v2.23.0.

You're on v2.7.4, which is 16 minor versions behind.

The latest release by the time of writing this is v2.31.0.
Which means you have to update your git version.


If you can't update your version for any reason, you can make a handy alias:

git config alias.restore '!f() { git checkout $(git rev-list -n 1 HEAD -- $1)~1 -- $(git diff --name-status $(git rev-list -n 1 HEAD -- $1)~1 | grep '^D' | cut -f 2); }; f'

and use it nearly the same way

git restore yourFile

Credits to @VonC for this solution.

0

Your Git version is too old. The "restore" command was added in version 2.23. You are running version 2.7.

You are probably not able to upgrade to a newer version because you are pulling from an older Linux distribution. I would suggest that you find a way to install a later Git via some other mechanism than what you are currently using to keep your Git up to date.

I believe that the following commands should let you install a more recent version via apt-get:

sudo apt-add-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

I got this from the post I give below. It appears to be a question and answer for the same problem you are having. You should check it out for yourself.

https://askubuntu.com/questions/568591/how-do-i-install-the-latest-version-of-git-with-apt

Not the answer you're looking for? Browse other questions tagged or ask your own question.