gituto/doc/undo_changes.org

1.4 KiB
Raw Permalink Blame History

Pro Git book notes

Undo

After adding the files you want to include into the commit. To include changes to your last commit, do this:

   git commit --amend

If after adding the files you want to unstage some files, use the "restore staged" argument:

  git restore --staged file1

Unmodify a modified (not staged) file

  git restore file2

Reverting commits

First, check logs to verify the commiy hash you want to revert:

  git log --oneline

Verify the commit you wish to revert (use commit hash as argument):

  git show 0114c758775d852a82f06ea439fdbc5200b36ed7

Then, revert it:

  git revert --strategy resolve 0114c758775d852a82f06ea439fdbc5200b36ed7
  git branch temp-branch
  git checkout master
  git merge temp-branch
  git push origin main
  git log --pretty=format:"%h %s" --graph