Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the Git- command

Shulou Source: shulou.com Published: 2022-06-02 06:09:05 09月21日 Update

This article mainly explains the "use of Git- command", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "the use of Git- command" bar!

Discard history

If the existing submission history: a-> B-> C-> D-> E-> F, and if you want to discard the previous submission history of C to make the history change to: C-> D-> E-> F, then:

Create a root submission based on C #, you can use git commit-tree

Change the base of Drecoe Epene F to the root submission that you just created. It is as follows:

$git log-- oneline-- decorate-- graph # current submission history * fdc7fff (HEAD, tag: F, master) F* d46f42d (tag: e) E* 6501e33 (tag: d) D* a0699ec (tag: C) C* b97d344 (tag: B) B* 7929c37 (tag: a) A $git commit-tree-m'C 'tags/ C ^ {} ^ {tree} # create a root submission 7b99fe372d8324172f88b814ff1bdffac97338b8 $git rebase-onto 7b99fe372d8324 C F # to perform a change base operation. First, reset the header pointer to replay your work on it. Positive application: d positive application: e positive application: F $git status # Note that the git rebase is in the state of detaching header pointer. # HEAD detached from 7b99fe3nothing to commit, working directory clean$ git checkout master # switch to master. Warning: you are leaving 4 submissions and are not associated with any branch: 4eb1223 F c5d1c66 E 9686a0e D 7b99fe3 C switches to branch 'master'$ git reset-- hard HEAD@ {1} # Note this step. $git status # is located on branch masternothing to commit, working directory clean$ git log-- oneline-- decorate-- graph # successfully deleted history * 4eb1223 (HEAD, master) F* c5d1c66 E* 9686a0e D* 7b99fe3 C Thank you for your reading The above is the content of "the use of Git- command". After the study of this article, I believe you have a deeper understanding of the use of Git- command, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: History usage commands methods branches learning applications content pointers switching success that is ideas situations articles more status knowledge knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Linux Microsoft Docker vpn