Tsallaka zuwa abun ciki
Justice Tech School

Getting a File from Another Commit

git restore --source takes a file from any commit.

Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt && git commit -qam 'second'
git restore --source HEAD~1 a.txt
cat a.txt
git status -s

Result

one
 M a.txt

Exercise

Source commit.

git restore -- HEAD~1 f

Quiz Test

What does --source choose?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.