Tesco will hand out food nearing its sell-by date free of charge in a bid to curb wastage and meet environmental targets.