git reset vs git revert

  • reset : rewriting the commit history. DON’T use it on pushed branches
  • revert : creat a new commit, but it reverse changes.

git cherry-pick

  • you would like to copy a series of commits below your current location (HEAD).
1
2
3
// master/HEAD is at C5
// pick C2 and C4 , add them to master
git cherry-pick C2 C4

  • useage

git describe

  • Describe a commit using the most recent tag reachable from it

mixed

situation

I want to do a slight modify on newImage, then move master to C3

  • starting

  • goal

  • sol1
  1. re-order the commits (rebase -i)

  2. commit –amend to make the slight modification on newImage

  3. re-order the commits back(git rebase -i)

  4. move master(git branch -f master )

  • sol2
  1. git cherry-pick C2

  2. commit –amend to make the slight modification on newImage

  3. git cherry-pick C3