2021年10月1日 星期五

Remove files from Git commit

 I will explain to you with example.

Let A, B, C be 3 successive commits. Commit B contains a file that should not have been committed.

git log  # take A commit_id
git rebase -i "A_commit_ID" # do an interactive rebase
change commit to 'e' in rebase vim # means commit will be edited
git rm unwanted_file
git rebase --continue
git push --force-with-lease <branchName>  


from: https://stackoverflow.com/questions/12481639/remove-files-from-git-commit

沒有留言:

張貼留言