[{"data":1,"prerenderedAt":290},["ShallowReactive",2],{"blog-entry-numbers":3,"notes-2025-04-14-dotenv-leak-lab":59,"references-notes-2025-04-14-dotenv-leak-lab":261,"related-blog-notes-2025-04-14-dotenv-leak-lab":274},[4,7,10,13,16,19,22,25,28,30,33,36,39,42,45,48,51,53,56],{"path":5,"date":6},"\u002Fblogs\u002F2024-01-14-setup-ubuntu-server","2024-01-14",{"path":8,"date":9},"\u002Fblogs\u002F2025-04-24-n8n-part-1","2025-04-24",{"path":11,"date":12},"\u002Fblogs\u002F2025-04-28-n8n-part-2","2025-04-28",{"path":14,"date":15},"\u002Fblogs\u002F2025-05-12-next-dns","2025-05-12",{"path":17,"date":18},"\u002Fblogs\u002F2025-05-18-from-old-notebook-to-home-lab-server","2025-05-18",{"path":20,"date":21},"\u002Fblogs\u002F2025-08-18-ollama-desktop-ui","2025-08-18",{"path":23,"date":24},"\u002Fblogs\u002F2025-08-26-xponology-on-old-pc","2025-08-26",{"path":26,"date":27},"\u002Fblogs\u002F2026-08-03-docker-dind-vs-dood","2026-08-03",{"path":29,"date":27},"\u002Fblogs\u002F2026-08-03-grafana-alloy-loki",{"path":31,"date":32},"\u002Fblogs\u002F2026-08-07-node-exporter-mtls-basic-auth","2026-08-07",{"path":34,"date":35},"\u002Fblogs\u002F2026-09-16-headroom","2026-09-16",{"path":37,"date":38},"\u002Fblogs\u002F2026-10-17-humanizer-skills","2026-10-17",{"path":40,"date":41},"\u002Fblogs\u002F2026-10-27-claude-code-server-management","2026-10-27",{"path":43,"date":44},"\u002Fblogs\u002F2026-11-02-agent-skills-security-check","2026-11-02",{"path":46,"date":47},"\u002Fblogs\u002F2026-11-04-ai-native-sdlc","2026-11-04",{"path":49,"date":50},"\u002Fblogs\u002F2026-11-06-seo-aeo-geo-ai-search","2026-11-06",{"path":52,"date":50},"\u002Fblogs\u002F2026-11-06-sshole",{"path":54,"date":55},"\u002Fblogs\u002F2026-11-09-ai-search-visibility","2026-11-09",{"path":57,"date":58},"\u002Fblogs\u002F2026-11-11-persona-review-subagents","2026-11-11",{"id":60,"title":61,"body":62,"date":239,"description":75,"draft":240,"extension":241,"faq":242,"meta":243,"navigation":244,"next":242,"ogTitle":245,"path":246,"pin":240,"prev":242,"recommends":247,"seo":250,"sitemap":251,"stem":256,"tags":257,"updated":259,"__hash__":260},"notes\u002Fnotes\u002F2025-04-14-dotenv-leak-lab.md","วิธีการลบ .env file ออกจาก git แบบถูกวิธี",{"type":63,"value":64,"toc":233},"minimark",[65,73,76,79,89,113,119,129,133,164,170,181,185,190,211,217,224,229],[66,67,68],"p",{},[69,70],"img",{"alt":71,"src":72},".env leak","\u002Fimages\u002F2025-04-14-dotenv-leak-lab\u002Fimage-0.png",[66,74,75],{},"สมมติว่าเราเผลอ commit ไฟล์ .env ที่มี API key ไปแล้ว และ push ขึ้น GitHub เราต้องรีบลบมันออกทันที เพราะข้อมูลอาจถูกนำไปใช้ได้",[66,77,78],{},"สำหรับวิธีการลบ .env file แบบถูกวิธีให้ทำแบบนี้นะครับ พร้อมแล้วไปลุยกันเลยย",[80,81,83,84,88],"h2",{"id":82},"_1-นำ-env-file-ไปใส่ใน-gitignore-ก่อน","1. นำ .env file ไปใส่ใน ",[85,86,87],"code",{},".gitignore"," ก่อน",[90,91,96],"pre",{"className":92,"code":93,"filename":87,"language":94,"meta":95,"style":95},"language-sh shiki shiki-themes material-theme-lighter one-dark-pro github-dark",".env\n.env.*\n","sh","",[85,97,98,107],{"__ignoreMap":95},[99,100,103],"span",{"class":101,"line":102},"line",1,[99,104,106],{"class":105},"sosa_",".env\n",[99,108,110],{"class":101,"line":109},2,[99,111,112],{"class":105},".env.*\n",[114,115,116],"blockquote",{},[66,117,118],{},".env.:* เช่น .env.production .env.local .env.development",[66,120,121,122,128],{},"แนะนำให้ลองใช้ ",[123,124,125],"a",{"href":125,"rel":126},"https:\u002F\u002Fwww.toptal.com\u002Fdevelopers\u002Fgitignore",[127],"nofollow"," ผมใช้เป็นประจำครับ เป็นเครื่องมือในการช่วยสร้าง gitignore ไฟล์ชั้นดีเลย",[80,130,132],{"id":131},"_2-ลบ-env-file-ออกจาก-git-แบบในทุก-ๆ-commits","2. ลบ .env file ออกจาก git แบบในทุก ๆ commits",[90,134,136],{"className":92,"code":135,"language":94,"meta":95,"style":95},"git filter-branch --index-filter \"git rm -rf --cached --ignore-unmatch .env\" HEAD\n",[85,137,138],{"__ignoreMap":95},[99,139,140,143,147,151,155,158,161],{"class":101,"line":102},[99,141,142],{"class":105},"git",[99,144,146],{"class":145},"sAlJX"," filter-branch",[99,148,150],{"class":149},"sEoV_"," --index-filter",[99,152,154],{"class":153},"snfNA"," \"",[99,156,157],{"class":145},"git rm -rf --cached --ignore-unmatch .env",[99,159,160],{"class":153},"\"",[99,162,163],{"class":145}," HEAD\n",[66,165,166],{},[69,167],{"alt":168,"src":169},"Output","\u002Fimages\u002F2025-04-14-dotenv-leak-lab\u002Fimage-1.png",[66,171,172,173,176,177,180],{},"ถ้าลบออกเฉย ๆ ด้วยคำสั่ง ",[85,174,175],{},"git rm -r --cached .env"," หรือ ",[85,178,179],{},"rm .env"," แล้ว commit ไปใหม่ สิ่งที่จะเกิดขึ้นคือไฟล์จะหายไปแค่ commit ล่าสุดเท่านั้น แต่ถ้าไปดูใน commit history ไฟล์ดังกล่าวจะยังอยู่ครับ",[80,182,184],{"id":183},"_3-push-git-ไฟล์อันใหม่ขึ้นไปด้วยคำสั่ง","3. push .git ไฟล์อันใหม่ขึ้นไปด้วยคำสั่ง",[114,186,187],{},[66,188,189],{},"คำเตือน: คำสั่งนี้จะเปลี่ยนแปลงประวัติทั้งหมดของ Project ควรแน่ใจว่าไม่มีใครใช้งาน repository นี้อยู่ก่อนจะ push ด้วย --force",[90,191,193],{"className":92,"code":192,"language":94,"meta":95,"style":95},"git push origin main --force\n",[85,194,195],{"__ignoreMap":95},[99,196,197,199,202,205,208],{"class":101,"line":102},[99,198,142],{"class":105},[99,200,201],{"class":145}," push",[99,203,204],{"class":145}," origin",[99,206,207],{"class":145}," main",[99,209,210],{"class":149}," --force\n",[66,212,213],{},[69,214],{"alt":215,"src":216},"Result","\u002Fimages\u002F2025-04-14-dotenv-leak-lab\u002Fimage-2.png",[66,218,219,220,223],{},"เพียงแค่นี้ ",[85,221,222],{},".env"," file ก็จะถูกลบออกไปจาก Git ของเราเรียบร้อยแล้วครับ",[114,225,226],{},[66,227,228],{},"Tip: ถ้าเคย push .env ขึ้น GitHub, Gitlab, Gitea หรือ Git Platform อื่น ๆ แล้ว อย่าลืมรีเซ็ต API key หรือ Token ที่อยู่ในไฟล์ด้วยนะครับ เพื่อความปลอดภัยสูงสุด",[230,231,232],"style",{},"html pre.shiki code .sosa_, html code.shiki .sosa_{--shiki-light:#E2931D;--shiki-default:#61AFEF;--shiki-dark:#B392F0}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sAlJX, html code.shiki .sAlJX{--shiki-light:#91B859;--shiki-default:#98C379;--shiki-dark:#9ECBFF}html pre.shiki code .sEoV_, html code.shiki .sEoV_{--shiki-light:#91B859;--shiki-default:#D19A66;--shiki-dark:#79B8FF}html pre.shiki code .snfNA, html code.shiki .snfNA{--shiki-light:#39ADB5;--shiki-default:#98C379;--shiki-dark:#9ECBFF}",{"title":95,"searchDepth":109,"depth":109,"links":234},[235,237,238],{"id":82,"depth":109,"text":236},"1. นำ .env file ไปใส่ใน .gitignore ก่อน",{"id":131,"depth":109,"text":132},{"id":183,"depth":109,"text":184},"2025-04-14",false,"md",null,{},true,"How To Remove .env From Git","\u002Fnotes\u002F2025-04-14-dotenv-leak-lab",[248,249],"2026-01-17-zshhistory.md","2025-04-25-setup-nuxt-medium-zoom.md",{"title":61,"description":75},{"loc":246,"images":252,"lastmod":239},[253,254,255],{"loc":72},{"loc":169},{"loc":216},"notes\u002F2025-04-14-dotenv-leak-lab",[258],"Development","2026-08-09","rMwg8odZHHRlrglHIQIhLHUfeQ3gVyWpB1W2lEmmuqc",[262,268],{"id":263,"path":264,"title":265,"date":266,"tags":267},"notes\u002Fnotes\u002F2025-04-25-setup-nuxt-medium-zoom.md","\u002Fnotes\u002F2025-04-25-setup-nuxt-medium-zoom","ติดตั้ง Medium Zoom ใน Nuxt 4 ให้คลิกรูปแล้วซูมแบบ Medium","2025-04-25",[258],{"id":269,"path":270,"title":271,"date":272,"tags":273},"notes\u002Fnotes\u002F2026-01-17-zshhistory.md","\u002Fnotes\u002F2026-01-17-zshhistory","วิธีแก้ไข zsh_history เสียหาย","2026-01-17",[258],[275,282,284],{"id":276,"path":277,"title":278,"date":279,"tags":280},"notes\u002Fnotes\u002F2026-03-30-how-to-use-uv.md","\u002Fnotes\u002F2026-03-30-how-to-use-uv","เริ่มต้นใช้งาน uv ตัวจัดการ Python แห่งยุค 2026","2026-03-30",[258,281],"Python",{"id":269,"path":270,"title":271,"date":272,"tags":283},[258],{"id":285,"path":286,"title":287,"date":288,"tags":289},"notes\u002Fnotes\u002F2025-12-28-zshrc-config-folder.md","\u002Fnotes\u002F2025-12-28-zshrc-config-folder","ย้าย .zshrc ไปยัง .config folder","2025-12-28",[258],1795352420537]