Git merge git merge git merge git merge
Git merge b #
Git rebase b merges the b branch into the current branch
Here’s how they work:
Suppose you now create a branch called “mywork” based on the remote branch “Origin”. $git checkout -b mywork Origin $git checkout -b mywork Origin
Now let’s make some changes in this branch and generate two commits. git commit git commit … But at the same time, some people have also made some changes on the origin branch and submitted it. This means that the origin and Mywork branches are going their own way, branching off from each other.
Here, you can use the “pull” command to pull down the changes on the “Origin” branch and merge them with yours; The result looks like a new merge commit:
However, if you want the “mywork” branch history to look like it hasn’t been merged at all, you might want to use Git rebase:Git rebase Origin cancels every commit in your “mywork” branch, I temporarily saved them as patches (put them in the “.git/rebase” directory), updated the “mywork” branch to the latest “Origin” branch, and applied the saved patches to the “mywork” branch.
When the ‘mywork’ branch is updated, it points to these newly created commits, and the old ones are discarded. These discarded commits are deleted if you run pruning garbage collection (see Git GC).
In the process of rebase, conflicts may occur. In this case, Git stops rebase and lets you resolve the conflict; After resolving the conflict, use the “git-add” command to update the index of the content. Then, you don’t need to execute git-commit.Git rebase is used to abort git rebase. Git rebase is used to abort git rebase. Git rebase is used to abort git rebase.
When we use Git log to see commit, the commit order is different. Let’s say C3 commits at 9:00am,C5 commits at 10:00am,C4 commits at 11:00am, and C6 commits at 12:00am. C7,C6,C4,C5,C3,C2,C1 The order of commits seen with git rebase is: Git rebase commits C7,C6 ‘, C5′,C4,C3,C2,C1 because C6′ commit is only a clone of C6 commit and C5’ commit is only a clone of C5 commit. C7 ,C6,C5,C4,C3,C2,C1