Undo unstaged work

Undo changes that have not been staged or committed to a file:

git checkout -- filename.txt

Undo commits

Undo last unpushed commit and keep changes in working directory:

git reset --soft HEAD^

Undo last unpushed commit and lose changes:

git reset --hard HEAD^


# Generate diff and save to file
git diff --name-status {commit1} {commit2} > file.txt

# Example
git diff --name-status b521ddfd8064c622471e0dabc7db2cfcef536713 c300d0553a95c20317e1f35f998d76843ae97b35 > file.txt