วิธีการ clear History ทั้งหมดของ Repository ใน Github
อันนี้เป็นการเตือนความจำของผมเองในกรณีที่ต้องการจะให้เก็บไฟล์ version ใหม่ล่าสุดไว้ แต่อยากลบ history ทั้งหมดทิ้ง สามารถทำได้ตามนี้ครับ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# Clone the project, e.g. `myproject` is my project repository: git clone https://github/yourrepo/myproject.git # Since all of the commits history are in the `.git` folder, we have to remove it: cd myproject # And delete the `.git` folder: rm -rf .git # Now, re-initialize the repository: git init git remote add origin https://github.com/heiswayi/myproject.git git remote -v # Add all the files and commit the changes: git add --all git commit -am "Initial commit" # Force push update to the master branch of our project repository: git push -f origin master |
จากนั้นกลับไปดู history ใน Github Dashboard ก็พบว่าสามารถต่อได้เรียบร้อยแล้วตรับ
Source:: Github