Pernah salah mengirim pull ke repository git dan ternyata file yang dikirim berisi data yang seharusnya tidak dilihat oleh orang lain?
Hapus terlebih dahulu file dari repo, misalkan nama file tersebut dnsencrypt.c

git rm -f dnsencrypt.c

kirim commit

git commit -m "hapus data rahasia"

setelah mengirim commit ini data anda tetap ada di history. Selanjutnya hapus data dari repository. Yang perlu anda ketahui adalah commit, contoh 607681bf20c686a334d85e6afcbadc615c75c0c2

git rebase -i 607681bf20c686a334d85e6afcbadc615c75c0c2

pilih commit yang mau anda hapus, contoh di file saya

pick de858a6 Upgrade versi dns
pick b3c5445 enskripsi file baru
 
# Rebase d18cb16..b3c5445 onto d18cb16
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

saya akan menghapus file dengan commit comment “enskripsi file baru”, hapus baris “pick b3c5445 enskripsi file baru” lalu simpan, dan terakhir push kembali

git push -f

Leave a comment

Your email address will not be published. Required fields are marked *