git fall back to version history

Problem Description

In the development process, the name you want to modify a parameter. Then modify various places, and push the cloud-based remote code repository. Then suddenly I found a need to change a lot of places, suddenly do not want to regret the change. Then how to do it?

Processing steps

  • Local git version rollback
  • The native code forces pushed to the remote repository

Local git version rollback

  • First check git version information, usegit log
Git log $ 
the commit . 6 fecbc4fc9d7e23f5c66a504a413cc1ed4ed7f0c (the HEAD - > Master , Origin / Master , Origin / Django -template , Origin / the HEAD , Django -template ) the Author : kubernete < 357 018 097 QQ @ .com > a Date : Thu-Aug 15 22 is : 24 : 16 2019 + number of parameters to modify a table 0800 called the line table the -lines the commit 0e149c39eb4401647a9468eaf2b68b45832dbcb2 the Author : kubernete < 357 018 097 QQ @ .com > a Date : Thu-Aug15 22 : 05 : 07 2019 + 0800 canceled tab menu of 360-degree flip animation Author 7c4b1492616ae788e9f58461c72fc12f6c9b1e2d the commit : lijw < 357 018 097 QQ @ .com > a Date : Thu Aug 15 19 : 44 : 24- 2019 + 0800 written inquiries to hide the list of equipment unit fill table shows the number of rows

Read the above git commit log, I do not want to modify the parameters of the number of table rows called table-lines of this code delivery, directly falls back to cancel tab menu of 360-degree flip animated version. It can be executed directly fall back to the previous version.

  • Execution falls back to the previous version, usegit reset --hard HEAD^
# Perform a version falls back on a submission 
$ git the RESET --hard the HEAD ^ 
the HEAD IS AT 0e149c3 now canceled tab menu of 360-degree flip animation 

# View log to confirm 
$ git log 
the commit 0 e149c39eb4401647a9468eaf2b68b45832dbcb2 (the HEAD - > Master ) Author : kubernete < 357 018 097 QQ @ .com > a Date : Thu Aug 15 22 : 05 : 07 2019 + 0800 canceled tab menu of 360-degree flip animation Author 7c4b1492616ae788e9f58461c72fc12f6c9b1e2d the commit : lijw < 357 018 097 QQ @ .com > a Date : Thu Aug 1519 : 44 : 24- 2019 + 0800 Writing Device crew list query displays the number of hidden fields filled table rows

Forced to push to a remote repository native code

But here, in fact, only local fallback version of it, and no remote repository rollback. If you want to push the local code directly to the remote warehouse will be given as follows:

$ git push
To gitee.com:kubernete/Performance-Test-Management-demo.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]:kubernete/Performance-Test-Management-demo.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Here you will be prompted to update the remote repository, if the update execution git pull, then they will just come back fallback version download.

At this point we need to force the native code pushed into a remote repository, usegit push -f origin master

Do the following:

Git the Push $ -f Origin Master 
Total 0 (Delta 0 ) , the Reused 0 (Delta 0 ) Remote : Powered By Gitee .com the To gitee .com : kubernete / Performance -Test -management -demo .git + 6fecbc4 ... 0e149c3 Master - > Master (Forced Update )
this version of history is GITHUB version, you can download it directly CLONE

article reprinted from: https: //cloud.tencent.com/developer/article/1490112

Guess you like

Origin www.cnblogs.com/yeshenmeng/p/11571161.html