chap 4 Flashcards
(8 cards)
The most common correction to make is to the previous commit: you run git commit, and then realize you made a mistake
git commit –amend // keep commit message
git commit –amend -m”new message”
Show all the changes that you have done
git log
git log -g
display the file as it was on a previouse commit
git show theid
i.e.
git show 5023185775fa522b4665929fb13286e48a257247
Discard the last commit
git reset HEAD~
Discard any number of commits
git reset HEAD~3 // 2, 3 4, etc
Discard options
Just know they exist for now
–mixed
The default: makes the index match the given commit, but does not change the working files. Changes made since the last commit appear unstaged.
–soft
This resets the branch tip only, and does not change the index; the discarded commit’s changes remain staged. You might use this to stage all the changes from several previous commits, and then reapply them as a single commit.
–merge
Tries to keep your outstanding file changes while rewinding the branch, where this makes sense: files with unstaged changes are kept, while files differing between HEAD and the given commit are updated. If there is overlap between those sets, the reset fails.
–hard
Resets your working files to match the given commit, as well as the index. Any changes you’ve made since the discarded commit are permanently lost, so be careful with this option! Resist the urge to make an alias or shortcut for using git reset –hard; you will probably regret it.
Undoing an earlier commit
git revert 9c6a1fad
This will compute the diff between that commit and the previous one, reverse it, and then attempt to apply that to your working tree (you may have merge conflicts to resolve if intervening changes complicate doing that automatically). Git will prepare a commit message indicating the commit being reverted and its subject, which you can edit.
Further reset stuff on page 63 onwards
Juts be aware foe now