Git rebase (rebase) operation

1, on Git提交the merge 以及 rebasedistinction here I no longer superfluous complaint, you can view information on their own.
The advantages are summarized as follows:
rebasing makes the submission history more tidy. When you look at the history of a branch that has undergone rebase, you will find that although the actual development work is parallel, they look like serial, and the commit history is a straight line without forks.

  • Before using rebase
    -Insert picture description here
  • After using rebase
    Insert picture description here

GitCommand implementation

Which releaseis the remote branch, webis the local branch

git add.
git commit -m ''
git checkout release  
git pull 
git checkout web 
git rebase release  
git checkout release 
git merge web
git push 
git checkout web 

TortoisegitTo achieve

3. First we have a remote main branch (develop) and a local branch (web).
We develop in our own local branch, and merge the code submissions from the local branch to the remote branch.
The steps are:

1. We develop in the local branch, so first switch to our own local branch (web) to submit the code.
Insert picture description here
2. Then we switch to the remote master branch develop to perform pull update operations to make the local code up-to-date.

Insert picture description here
3. Switch back to the local development branch (web) and rebase.
Insert picture description here
The upstream branch selects the develop branch.
Insert picture description here

If the code of the current branch and the remote branch are the same, they are both the latest. You can omit the second step and proceed directly to the forced rebase operation in the above figure.
4.
Then switch back to the main branch develop to merge (web), and then push operation.
Insert picture description here
Insert picture description here
Insert picture description here

5. After the above steps, the rebasing operation is completed. Compared with direct submission, the operation is a bit more complicated.

Summarize ideas

  • First, whether your current branch is a local development branch, if it is a remote branch, first perform a pull update operation to ensure that your local code is up to date.
  • Then switch to the local development branch to commit
  • If the update has been pulled in the remote branch, proceed directly rebase, otherwise, first switch to the remote branch to update
  • Switch to the remote branch for merge commit

6. Attach a picture of GIT commonly used commands:
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45416217/article/details/108196521