Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a recursive 'git checkout'?

Tags:

git

I have a parent directory and inside that directory there are multiple sub-directories which contain .git directories consisting of objects.

How do I run 'git checkout -f .' recursively for each sub-directory?

like image 335
jozumuc Avatar asked Oct 20 '25 09:10

jozumuc


1 Answers

Can use the following command inside parent directory

find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} checkout -f \;

maxdepth 1 - looks only for subdirectories type d - looks only for directory type

like image 176
Srishti Avatar answered Oct 21 '25 23:10

Srishti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!