Can we backtrack multiple files simultaneously?

Question

As we seen in this lesson, we can stage and commit multiple files simultaneously. Can we also backtrack on multiple files at the same time?

Answer

The answer is yes if each of the files that you would like to backtrack are in the same commit and the same branch. If this is the case, then as we see from git status, we can backtrack to the previous commit using the command

$ git checkout -- <file> ...

where the ellipses are replaced by other files which you would like to backtrack.

4 Likes

I’d just like to add that in that particular exercise you can add/backtrack/commit multiple files with this syntax:

git add scene*

which is easier than scene-1.txt scene-2.txt scene-3.txt…

:slight_smile:

2 Likes

Or you can just do this

git add .