my header.php page got erased when i trying to post google tag manger code , how can i retrieve it, rest of the theme is ok

If it’s a prebuilt theme (i.e. you downloaded it from WordPress.org or bought it somewhere), go to the author’s website and download a fresh copy. If it’s a custom theme, you’ll need to rely on your own backups – perhaps you’re auto backing up to a Dropbox, or you’re using a host that provides file backups.

In either case, if you’ve only modified header.php, you can FTP in, delete the file, and upload just the header.php from your backup source.

Also in either case, it’s never a good idea to use the “edit files” option in wp-admin, or to modify a theme. It’s safest to create a child theme and upload it via FTP. That way you’re adding new files, not modifying old ones, and as the parent theme gets updated your overrides like GTM will stay in place.