Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the skills of using Git?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what skills you have in using Git. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

1. Git common command diagram

Workspace: workspace

Index / Stage: temporary storage area

Repository: local warehouse

Remote: remote warehouse

two。 Undo just git add (temporary file) git reset head

(2) # git commit-amend

After the above command is executed, it will be transferred to the text editing window

Change the comment information here to the comment information you want, such as "modify comment information", and save

(3) re-push to the server

Git push origin master-f

At this time, the comment information of the server is already the one that has just been modified.

Note: there is a simpler way to modify the comment information of * once commit, as follows:

# git commit-- amend-m "submit comment information"

5. Modify the historical annotation information of commit

(1) use git rebase-I head~2 (~ 2 refers to listing the first two submission records of the current version)

Git rebase-I head~2

Jumps to the text editing window

A total of two historical submission messages are listed. Change the pick field to edit for the one you want to modify. For example, change the * bar to edit, and then save the exit. You can find that the * submission of git has become the one you selected through the git log command.

(2) then you can modify it through the git commit-- amend command.

(3) after modification, use the git rebase-- continue command to return

(4) git push origin master-f

6. Version fallback

(1) use git log to view historical submission information, such as

(2) if you want to go back to the submitted version of "New index.html Page"

Git reset-hard bebdaf328533d2517875a3db7d1aabc2834f2d59

Note:-- the hard parameter will discard the changes to the current workspace after you roll back the version

-- the soft parameter can retain the changes to the current workspace after the fallback version

(3) push to remote server

Git push origin master-f

Note:-f is a forced push, otherwise the server will reject the push

7. The easiest way to merge multiple commit

For example, to merge three submitted commit into a single commit

(1) revoke 3 commit of *

Git reset head~3

(2) create a new commit submission

Git commit-am "submit comment information"

Note: parameter-am differs from-m in that-m submission requires git add to join stage before commit submission, while-am is equivalent to the combination of add and commit and can be directly commit, but only if the modified file has been tracked

This is the end of this article on "what are the skills for using Git?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report