Let's go into details today git All kinds of orders , This is a git The first chapter of , There will be several more in the future , I hope you can make progress after watching it

The first order

1.git commit

2.git branch

3.git merge

4.git rebase

Git Commit

Git The submission records in the warehouse keep a snapshot of all the files in your directory , It's like copying the entire directory , And then paste the same , But it's much more elegant than copy and paste !

Git Want to submit records as light as possible , So every time you submit , It doesn't blindly copy the entire directory . If conditions permit , It compares the current version with the previous version in the warehouse , And package all the differences together as a submission record .

Git It also keeps a history of submissions . That's why most submitted records have parent nodes on them . For members of the project team , Maintaining the submission history is good for everyone .

We won't go further into the matter of submitting records , Now you can think of the commit record as a snapshot of the project . Submitting records is very light , You can quickly switch between these submission records !

Git Branch

Git It's also very lightweight . They simply point to a submission record —— That's it . So many Git Fans chant :

Build a branch early ! Multi use branches !

This is because even if you create more expenses, it will not cause storage or memory overhead , And it's much easier to work logically into different branches than to maintain those particularly bloated ones .

Just remember that using branches is equivalent to saying :“ I want to do new work based on this submission and all of its parent submissions .”

Branching and merging

Merge two branches together . That is to say, we have a new branch , Develop a new function on it , After the completion of development, merge back to the main line .

Let's take a look at the first way —— git merge. stay Git A special commit record is generated when two branches are merged in , It has two parent nodes . Translation into natural language is equivalent to :“ I want to include the two parent nodes themselves and all their ancestors .”

1. We have two branches , Each branch has a unique commit . This means that no branch contains all of the changes we made . Let's solve this problem by merging the two branches .

We are going to put  bugFix  Merge into  master  in

git merge bugFix

wow ! See that ? First ,master  Now it points to a commit record with two parent nodes . If from  master  Start looking up the arrow , On the way to the starting point, we will pass all the submission records . It means  master  Contains all changes to the code base .

git The second way to merge branches

Git Rebase

Rebase It's actually taking out a series of submission records ,“ Copy ” they , And then put them in another place one by one .

Rebase The advantage is that you can create a more linear submission history , It sounds a little hard to understand . If only allowed to use Rebase Words , The commit history of the code base will become very clear .

Or two branches ; Note that the current branch is bugFix( The asterisk identifies the current branch )

We want to put bugFix The work in the branch moves directly to master On the branch . After the move, the functions of the two branches will appear to be developed in sequence , But they are actually developed in parallel .

Let's use  git rebase  To achieve this goal

perform  git rebase master

Running results :

Be careful , Submit the record C3 There is still a ( The translucent node in the tree ), and C3' It is our Rebase To master On the branch C3 Copy of .

Now the only problem is master Not updated yet , Let's update it ……

Now we switch to  master  On . Take it rebase To  bugFix  On the branch

perform git rebase master

Running results :

git Detailed command ( One ) More articles about

  1. Git On -- Note taking and Git Detailed command

    Several important concepts First of all, let's clarify a few concepts : WorkPlace : work area Index: Temporary storage area Repository: Local repository / Version Library Remote: Remote warehouse When in Remote( Such as Github) above c ...

  2. Git Detailed command

    A Chinese git manual :http://progit.org/book/zh/ original text :http://blog.csdn.net/sunboy_2050/article/details/7529841 The first two ...

  3. git Detailed command ( 7、 ... and )

    This is a git The seventh chapter of command detailed explanation We can gradually uncover this chapter git push.fetch and pull The mystery of . We will introduce these orders one by one , They are very similar in concept .   git push Parameters of git ...

  4. git Detailed command ( Four )

    This is git The fourth part of the order explains in detail , Don't talk much , Let's go straight to knowledge git Push Deviated work gitPush: This command is responsible for uploading your changes to the specified remote warehouse , And merge your new submission records on the remote warehouse . once  git ...

  5. Git Command details and common commands

    Git Command details and common commands Git As a common version control tool , Learn more about commands , It will save a lot of time , The picture below is a better one , Post it and have a look : About git, First of all, we need to know a few nouns , as follows : 1 2 3 4 Work ...

  6. git Detailed command ( Two )

    This is a git The second part of detailed explanation , Recently, this overtime work is a little empty , So I'm lazy to write , I have to work overtime , Chinese wolfberry in a thermos cup , No more , Today we'll look at it git The second part of This article is mainly about git Some remote commands for Remote warehouse git clo ...

  7. Git Detailed command ( One )- personal use

    For the time being, this article won't cover how teams use Git The content of , It's about how to make good use of Git. Appointment Green 5 Bit characters for submitted ID, In this paper, we use <commit> Express , Point to parent node respectively . The branches are shown in orange , They point to the special ...

  8. git Detailed command ( 6、 ... and )

    This is a git The sixth part of the order Remote tracking Branch I don't know if you have found it in the previous articles Git Seems to know  master  And  o/master  It's related. . Of course, the names of these branches are similar , It might make you feel like you're branching remotely mas ...

  9. git Detailed command ( 8、 ... and )

    This is a record git Chapter 8 of , The first seven chapters are remote chapters , The first seven articles are most commonly used in work , Because we need to work together on remote branches     Move on commit tree Cancellation of change Move on commit tree In contact with Git Before more advanced features , We need to learn in your project first ...

  10. git Detailed command ( 3、 ... and )

    This is git The third part of the order Catalog git Pull Simulate teamwork Git Pull At the end of the last article we already know how to use  git fetch  Get remote data , Now we learn how to update these changes to our work when ...

Random recommendation

  1. 【 handy 】JavaWeb Entry level project practice -- Article publishing system ( Section 12 )

    well , So in the last section , The backstage of the comment function has been written , This section , First, connect this part of background code with the front desk . 1. Comment function is realized Let's modify the click event of the save comments button , use jQuery Get the value in the text box in the same way , And then through aja ...

  2. 【BZOJ】2434: [Noi2011] Ali's typewriter

    The question Here are some strings .\(m\) Time to ask , Every time you ask, the second \(x\) A string in \(y\) How many times in the string .( Enter the total length $ \le 10^5$, \(M \le 10^5\)) analysis stay ac On automata ,\(x ...

  3. Linux System command query package

    Reprinted from :http://blog.chinaunix.net/uid-346158-id-2131252.html,http://www.jb51.net/os/RedHat/1102.html, One . ...

  4. css in the light of ( Browsers 、 Various versions ) Tone compatibility

    ie6\ie7\firefox They are identified by each other CSS Symbol #1 { color: #333; } /* firefox */ * html #1 { color: #666; } /* IE6 */ * ...

  5. IController The creation process of the controller

    .NET/ASP.NET MVC Controller controller ( Two :IController The creation process of the controller )   Read the directory : 1. Introduction to 2.ASP.NETMVC IControllerFactor ...

  6. ASP.NET Core 2.0 in Docker on Windows Container

    install Docker for Windows https://store.docker.com/editions/community/docker-ce-desktop-windows If you want to ASP. ...

  7. 2018-2019 20165237 Cyber warfare Exp4 Malware Analysis

    2018-2019 20165237 Cyber warfare Exp4 Malware Analysis The goal of the experiment 1.1 It's about monitoring your own system , See if there are suspicious programs running . 1.2 It's analyzing a malware , Just analyze Exp2 or Exp3 After being generated in ...

  8. window Remote deployment under the system Tomcat

    The remote access windows System , stay windows Start on the system tomcat, Publish the project .1. allocate VPN2. Remote Desktop Connection ,cmd --> mstsc enter , The remote desktop connection window pops up 3. Enter the computer IP:132.2 ...

  9. WEB Introduction 2 Forms and forms

    Learning content Ø         The function and making of forms Ø         Form making Capability objectives Ø         Master the creation of forms Ø         Master the common properties of setting tables : Ø         Understand the role of forms Ø ...

  10. Maven Study two : Use Nexus build Maven Private service and related configuration

    In consideration of safety and other reasons , Some internal networks are not allowed to access external networks , But the project built inside the project is Maven framework , In this way, enterprises need to build their own network in the internal network Maven Warehouse Services , In addition, some large enterprises or internal modular component Division ...