The author likes to talk

At the beginning of August, Hangzhou is getting hotter, but looking at the beautiful weather, the mood is still very good.


Recently saw “Summer of the Bands”, was Muma Trojan, crazy fan, the band lead singer Muma said: “The Trojan was like a toy we broke, now we got it back, it’s a new Trojan” (background: Muma Trojan broke up)

All of a sudden, I remembered the band I had formed with several upperclassmen in college. The time of basement rehearsal was very simple and happy, but maybe the biggest regret in college was that I did not stick to this band to the end.

Back to Muma Horse, after listening to Muma Horse’s “King of Old City”, I feel that the lyrics are very interesting and very abstract. On Zhihu, many people say that the lyrics are deliberately pieced together, but I still think that the author has his own ideas and faces off with The Times in a sincere and playful way

All the prosperity has fallen and left a man as king, in the vortex of The Times lost his helmet and armour, but no matter when we never forget that the hero we often fantasize about actually lives in their own hearts -Muma Horse


Introduced the Git

Manager Wang πŸ€“ : Hao Meili, why don’t you submit the code you wrote last week to the branch?

Mei: Manager, the turtle is being thrown around. I feel so sorry for him. whoops

Little beautiful turtle

Manager Wang:??

Xiao Lin: 😍 😍 😍 😍 😍

Manager Wang looked at the poor eyes of Xiao Mei and felt that Xiao Mei should be really distressed turtle: “Ahem, for the sake of taking care of the little beauty, that we have today is how to use git in idea, we open our idea, to clone the this project, the project address is this https://github.com/maerduduqi/test

Hao Meili: Manager, you are too nice not to mistreat tortoise, start from us

Manager Wang: EMMM

Manager Wang: Linbu, ask you to open idea, why do you open Google browser?

Xiao Lin: Manager, you asked me to download the Clone project, I boarded to download the project down, and then decompress, and then open in idea ah

1. Clone project in Idea

Manager Wang: You are silly in my imagination and beyond my expectation

We can open our project directly in Idea

Click File -> New -> Project From Version Control

Ok, now this project has been clone down by us

Manager Wang: Let me ask you a question. What is the biggest purpose of using Git?

Hao Meili & Lin Bubo: No cavities! (This terrier, can Get to πŸ˜‚)

2,在 Idea ι‡Œ commit and push

Manager Wang: Yes, that is to submit the code we write and cooperate with others. That is to commit and push. It is also very easy to use this operation in Idea

Xiao Lin: Manager, let me interrupt you, are there only blue and red documents? There is no green, I like green most, small beauty and I said, want to live well, the body must take some green, I think small beauty said is very reasonable ah.

The manager cast an inquiring look at Xiao Lin

There’s actually green, and there’s gray and white

  • Green indicates that the code file has been versioned but not yet committed
  • White indicates that the code file is under version control, committed and unchanged
  • Gray: Code files are ignored by version control

Back to the submission

Lin bu move: ha ha ha, so simple, is it right

Manager Wang: There is only one step left, but the push is successful

Manager Wang: OK, we have successfully pushed now

3. View submission records in Idea

Lin Buzhan: Manager, I want to see what Xiao Mei submitted. How should I read it

Manager Wang: This is also very simple. Let me operate it

Xiao Lin: Mei said I was stupid. Can I withdraw this submission?

Manager Wang: Yes. Just so we can pull back

4. Resolve conflicts in Idea

Xiao Lin: The manager can do that. Manager, can you show me how IDEA resolves the conflict simulation scenario

Manager Wang: Certainly

Suppose there is another developer working on the same project and writing the same file. The workflow is as follows:

TXT, and continue writing code on the conflic.txt file.

2.02 Update the project code and write the code in conflic. TXT. After writing the code, submit it to the remote server.

3. When programmer 01 finishes writing the code and is ready to submit the code, the normal operation method at this time is to update the code first and then submit the code. However, conflicts will inevitably occur during the update, because the updated code conflict. TXT is inconsistent with the local repository code conflict. TXT

Before submitting, I want to update, conflict:

Solutions are as follows:

  • Accept yours;
  • Accept Theris: indicates that the updated file shall prevail;
  • Merge: indicates a manual merge
  • The common way to resolve conflicts is to merge

Click “>>” to merge the required content into the result, click “x” for the unnecessary content, and click Apply after the merge is complete.

It is worth noting that all “x >>” symbols need to be processed by clicking “x” if not needed, and “>>” if needed.

Xiao Lin: impressive, manager 🀀

Mei: Manager, I also want to ask a question

Manager Wang: Just ask and I won’t

5. Use branches in Idea

Mei: Can you teach me how to use git branches in Idea?

Manager Wang: it’s a piece of cake. Next, I’ll give you a simulation of the new and combined use of branches.

1. Develop a website.

Create a branch (named ISS53) to implement a new requirement, issue (#53 issue).

3. Work on this branch.

Just then, you get a call about a serious problem that needs urgent repair. You will do this as follows:

1. Switch to your production branch.

2, create a new branch for the urgent task (named hotFix) and fix it in it.

3. After the test passes, switch back to the online branch (named: master), merge the patch branch, push the changes to the online branch, and remove the HotFix branch.

4. Switch back to the branch you started working on (ISS53) and continue working.

5, after the iss53 problem is resolved, merge the iss53 branch to the master trunk and delete the ISS53 branch.

When we decide to implement a new requirement, how do we create a branch?

Fill in the branch name

Developed on the ISS53 branch, as follows

Push the branch to the remote repository

Click Push to push to the remote warehouse

The branch moves forward as the work progresses

Now that you get that call, there’s an urgent problem for you to solve.

With Git’s help, you don’t have to mix this emergent issue with iss53 changes,

You also don’t have to go through a lot of effort to restore the changes you made to the # 53 issue, then add the changes to the emergency issue, and then commit the changes to the online branch. All you have to do is switch back to master.

The operations on idea are as follows:


Note: Before you do this, be aware of any uncommitted changes in your working directory and staging area, which may conflict with the branch you are checking out and prevent Git from switching to that branch. The best thing to do is to keep the branches clean before you switch them.

There are ways around this (i.e., stashing and commit amending).

At this point, your working directory is exactly the same as it was before you started #53, and you can now focus on fixing urgent issues.

Keep in mind that when you switch branches, Git resets your working directory to make it look like it’s back to the last commit you made on that branch.

Git automatically adds, removes, and modifies files to ensure that your working directory is the same as it was when the branch was last committed.

Next, you need to fix the emergency problem. Let’s set up a hotfix branch for the urgent problem and work on it until the problem is resolved:


Based on the master branch emergency problem branch Hotfix code development, simulation is as follows:


You can run your tests, make sure your changes are correct, and then commit the code to the remote repository the same way you committed iss53.

When the hotfix emergency branch is complete, merge it back into your master branch for deployment online. You can use the Idea Git merge to do this:

So let’s go to master first

And then, merge the hotFixes on the master line, which is very important, because it’s the master line, merge the hotFixes on the master, don’t do it in the wrong order

And then, merge the hotFixes on the master line, which is very important because it’s the master, merge the hotFix code on the master, and don’t get the order back

Now that the latest changes are in the commit snapshot pointed to by the Master branch, you only need to commit the master to the remote repository (very important, don’t forget) and you can start publishing the fix.

Once we have successfully merged into the master line, we should then remove the branch hotfix

Delete the local repository branch Hotfix

Delete the remote repository branch hotfix

So let’s go back to our branch

Continue writing code on the iss53 branch

To summarize

Manager Wang: Where is the scream?

Xiao Lin: Who cares about you after all? It’s time to get off work

There are definitely more techniques to use Git in Idea than this, so I hope you can try more and click each button a little bit.

After all, Lu Xun said: Git this thing, more use to know

Refer to the article: https://www.cnblogs.com/newAndHui/p/10846276.html