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 knowledge points of Git mechanism?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "what are the knowledge points of Git mechanism". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "what are the knowledge points of Git mechanism"!

One or two git commits to not the same remote branch

Here due to the submission of their own code for the first time submitted to the A branch, the second time submitted to the B branch, and then reported wrong, here after the error, will prompt a Baidu internal link, you click on the link can follow the prompt to modify, can be said to save a lot of things, do not have to go to Google Baidu to solve, development efficiency also improved a lot

In the picture above, there is a prompt line of 6e8713 f is CR parent commit, which is highlighted and will be used later.

resolution process

Your current operation scenario is shown below, because multiple commits of a CR(review) cannot be pushed to different refs/for/[branch name](which may lead to subsequent review merge failure):

What does the judge mean, explain it here. The process of local development is first pulled from your remote branch A to the local branch. The remote branch is a clone of the master branch. After the local development is completed, it needs to be submitted to your remote branch. After submission, it must be reviewed by others. When other colleagues review, they mainly find out the irregularities and logic. After you have modified it, you can merge it into your remote branch A. Then, from your remote branch A to master, you can complete the code warehousing.

My ultimate goal for this merge is to merge into branch B (the first commit is branch A, the second is branch B)

If you expect commit 1 and commit 2 to merge into branch B:

Please roll back the local commit and merge it into the same commit push to branch B (a new review will be generated)

$git reset --soft [CR parent commit] (see push error message for CR parent commit) 6e8713f is CR parent commit) $git commit -m"commit message" $git push origin HEAD:refs/for/[branch B]

If file A has not been modified, but when resubmitted for review, it is still found that A has been modified. You use git diff and do not find any difference between your local file A and remote branch A. You need to undo the modification.

Do not add blank lines carelessly

It's about undoing a file that's already been submitted.

how to operate

1. Undo cache modifications

git reset HEAD filename

Undo changes to workspace

git checkout --filename III. git conflict resolution

The above picture is when submitting the code, a conflict occurred, still very considerate, Baidu this code review system still gave a prompt, according to the prompt operation a wave.

Step1. In the local repository, update and merge the code git fetch originit rebase origin/masterStep2. Open the conflicting files according to the prompts and modify the conflicting codes one by one.

You can see that there is head and your submission information, head is a remote branch, git commit -m "commit submission information" in this command I fill in the task 689, you can see that every information inconsistency, in your conflict file will be prompted.

What we need to do is resolve conflicts, compare remote and local conflicts, keep the code you need, and remember to delete the head and 689 tasks (commit messages) that are not in the code.

Or do not need such a little modification, you already know what kind of code you need to submit, then directly copy the code you are sure is OK into this conflict file, and then git three times can be

Step3. After all conflicts have been corrected, submit the modified code git add -ugit rebase --continueStep4. Update patchgit push origin HEAD:refs/for/master

How to cancel commit commit, skillfully execute the following two commands:

git add *git commit -m "Prompt A"

You find that your prompt message is written incorrectly, thinking git commit -m "prompt message B", but since git commit has been done, it will prompt you that there is nothing to git commit. How to cancel git commit at this time?

git reset --soft HEAD^

So the last commit is withdrawn, and then continue to execute git commit -m "prompt B".

At this point, I believe everyone has a deeper understanding of "what are the knowledge points of Git mechanism". Let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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

Internet Technology

Wechat

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

12
Report