Use git cherry-pick and revert rescue error code submitted

Most novice such a problem will arise when new to git. Code is finished, submitted to the dev branch for testing. Forget a happy cut back, and shoved found continue to be submitted after the dev branch development, to finish, I rely on, how I write code in dev above, when the heart must be a riot. Do not party!

  • To, replicate the accident scene
    • git checkout feature_1
      touch a.txt
      git add a.txt
      git commit -am "create a.txt"
      git checkout dev
      git merge feature_1
      git push origin dev 
        
      touch b.txt
      git add b.txt
      git commit -am "create b.txt"
      -- git checkout 好像不对

 Theoretically we create a second file should be in feature_1 branch, results are not careful the code written on the dev branch submitted. At this time, this time we want to submit to withdraw, but the code have to be preserved and ported to feature_1 branch  

  • Come on the code
    • log Git  ## in case the branch dev
    • git checkout feature_1 ## copy handover branch content to commit the branch feature_1

    • git cherry-pick 35af160a63bff3654b9e1d434b17e77f3ecea0ef
    • cherry-pick can submit other branches merged into the current branch
  • The code has been ported over. The rest is revoked dev code submitted
    • git checkout dev 
    • git revert 35af160a63bff3654b9e1d434b17e77f3ecea0ef

So far problems are solved      

 

Guess you like

Origin www.cnblogs.com/nightOfStreet/p/11222550.html