git version returned, modify, undo file operations

 

  •                                                                           git version return

  •                                                                           git modify the file

                                      git version return

  1. We learned how to modify the file yesterday but when we changed too many times, and has been uploaded to the repository, and how do we do? Here it is necessary to return the version, first of all we will start with git log to view the history version of our submission.

    Here we find that we have submitted three papers, but I want to return to the first version of the document before submitting our use git reset means --hard ~ 2 (2 is to file a submission from the beginning of the last return forward meaning twice) before returning to the documents submitted twice, in order to facilitate understanding, we will start with git log look at the history of our filings with the repository. From the figure we can see that price has broken version of the file back to the first version of our submission.
  2. There is a method of directly version return to return to the previous version, we still use git reset --hard version number for return , we will have to return to version first presented at the top, this time I want to go back I submitted the second version, enter git reset --hard d0f24c38,

    Try, compare git log in with a look at history. We have found a successful return.

                               git modify the file

  1. For convenience we see the effect, first before modifying  cat look inside the content lianxi.txt

  2. If we just changed the file without any operation, then we can delete the files inside, so directly modify completed . If our file has been submitted to the cache go, it is to use git add statements submitted, we use git checkout --lianxi.txt revoke modify, before once again we want to add files 666666666666666666 changed a bit, we look with cat ,

    已经修改完成,这是我还没有将文件提交到缓存区,我们用git checkout --lianxi.txt 文件会回到最后一次提交到版本库的初始状态,我们用git add先将文件提交到暂存区,之后我们在添加依据88888888888888888888修改一下文件,在撤销修改一下看一下现象。

    注意 git checkout -- file如果要是--写得不对就成了创建分支了!

 

如果我写的文章帮助了你,别忘了给我点赞哦。如果想和我一起学习进步可以关注我一下

本人QQ:2992789432

 

发布了45 篇原创文章 · 获赞 96 · 访问量 1万+

Guess you like

Origin blog.csdn.net/qq_40831778/article/details/102478585