混水摸魚

[ Linux ] GIT 取消上次的commit

在使用git commit 的時候,會不小心推上一個有問題的版本,雖然後可以再推新的修正的版本上去,但就是會多一個失敗的commit在上面,這時就可以取消上次的commit。

將head指向上一個commit
git reset HEAD^^C

將制推到git origin main
git push origin main –force
出現權限問題
remote: GitLab: You are not allowed to force push code to a protected branch on this project.

開啟你的專案->Settings->Repository
在下面Branch 你要將制推上去的分支後面 Allowed to force push 這個選項開啟即可。

Leave a Comment

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *