//to remove the last commit, but preserve changesgit reset --soft HEAD~1
//to remove unneded file from the staging areagit reset HEAD `<your file>`
//finally make a new commitgit commit -m 'Your message'
git log # take A commit_idgit rebase -i "A_commit_ID" # do an interactive rebasechange commit to 'e' in rebase vim # means commit will be editedgit rm unwanted_filegit rebase --continuegit push --force-with-lease <branchName>
Here is the step to remove files from Git Commit.
>git reset --soft HEAD^1(either commitid ) -- now files moved to the staging area.>git rm --cached filename(it will removed the file from staging area)>git commit -m 'meaningfull message'(Now commit the required files)