git reset HEAD~2 # undo last two commits, keep changes git reset --hard HEAD~2 # undo last two commits, discard changes
Remove a file from git without removing it from your file system
1 2
git reset filename # or git rm --cached filename echo filename >> .gitingore # add it to .gitignore to avoid re-adding it
git-amend 操作可以对commit message进行amend操作
Clean up local commits before pushing
1 2 3 4
git rebase --interactive # if you didn't specify any tracking information for this branch # you will have to add upstream and remote branch information: git rebase --interactive origin branch