Connect to Git branch creation and merging. When merging branches, there are two ways: git merge and git rebase.
git merge: Merge and submit two branches into a new submission, and the new submission has 2 parents.
git rebase: will cancel each submission in the branch and store them temporarily, then update the current branch to the latest origin branch, and finally apply all submissions to the branch .
git merge
Specific operations: bob modified 2 times in index1.html and submitted it to the remote warehouse; lilei modified 2 times in index.html times and submit it to the remote warehouse; bob pulls the remote warehouse (git fetch origin dev) and merges it. The branch structure is as follows:
It can be seen that the two branches are merged, and the 93a6d33 commit has 2 parents (135b375 and 8b61b04).
git rebase
Specific operations: lilei modified 2 times in index.html and submitted it to the remote warehouse; bob modified 2 times in index1.html and submitted it to the remote warehouse. Submit, pull the remote warehouse (git fetch origin dev), rebase and merge. The command line output is as follows:
First move the HEAD pointer to the top of the current origin branch, and then apply all commits to the current branch. The branch structure (in a straight line) is as follows:
It can be seen that during rebase, the current branch will commit 191b8cd, 00e08ec and the following two submissions based on the common ancestor of 135b375 , a total of 4 submissions were withdrawn. Then move HEAD to commit 322ca9 and reapply the 4 commits to the branch.
The above is the detailed content of The difference between git merge and rebase. For more information, please follow other related articles on the PHP Chinese website!

Answer: The steps involved in creating a Git project include: Install Git. Initialize the Git repository. Add files to the temporary storage area. Submit changes and add a description. (Optional) Create a remote repository. (Optional) Push (upload) changes to the remote repository.

How to add a public key to a Git account? Step: Generate an SSH key pair. Copy the public key. Add a public key in GitLab or GitHub. Test the SSH connection.

为 Git 添加环境变量的方法:修改 .gitconfig 文件。 Add env = KEY=VALUE in the [core] block. Save and exit the file.重新加载 Git 配置(git config --reload)。验证环境变量(git config --get core.env.MY_ENV_VAR)。

Use git to submit code separately, providing granular change tracking and independent work ability. The steps are as follows: 1. Add the changed files; 2. Submit specific changes; 3. Repeat the above steps; 4. Push submission to the remote repository.

To detect SSH through Git, you need to perform the following steps: Generate an SSH key pair. Add the public key to the Git server. Configure Git to use SSH. Test the SSH connection. Solve possible problems according to actual conditions.

To query the code uploaded to the Git repository, use the following command: View the commit record list: git log By commit hash query: git log <Commit hash>Search by commit information: git log -S <Search string>Query by file path: git log -S <Search string> -- <File path>Compare changes between two commits: git diff <Start commit hash> <End commit hash>View special

Connecting a Git server to the public network includes five steps: 1. Set up the public IP address; 2. Open the firewall port (22, 9418, 80/443); 3. Configure SSH access (generate key pairs, create users); 4. Configure HTTP/HTTPS access (install servers, configure permissions); 5. Test the connection (using SSH client or Git commands).

After committing to the wrong branch, you can resolve it by: Determine that the wrong branch creates a new branch, pointing to the correct branch apply the commit to the new branch Push the new branch to the remote repository to delete the wrong branch. Force update the remote branch


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools