1, on Git提交
the merge 以及 rebase
distinction 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
- - After using rebase
Git
Command implementation
Which release
is the remote branch, web
is 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
Tortoisegit
To 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.
2. Then we switch to the remote master branch develop to perform pull update operations to make the local code up-to-date.
3. Switch back to the local development branch (web) and rebase.
The upstream branch selects the develop branch.
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.
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: