git 撤销合并 重新合并
Welcome to our ultimate guide to the git merge
and git rebase
commands. This tutorial will teach you everything you need to know about combining multiple branches with Git.
欢迎来到git merge
和git rebase
命令的最终指南。 本教程将教您有关将多个分支与Git结合使用所需的所有知识。
Git合并 (Git Merge)
The git merge
command will merge any changes that were made to the code base on a separate branch to your current branch as a new commit.
git merge
命令会将在单独分支上对代码库所做的所有更改作为新提交合并到当前分支。
The command syntax is as follows:
命令语法如下:
git merge BRANCH-NAME
For example, if you are currently working in a branch named dev
and would like to merge any new changes that were made in a branch named new-features
, you would issue the following command:
例如,如果您当前正在一个名为dev
的分支中工作,并且想要合并在一个名为new-features
的分支中所做的任何新更改,则可以发出以下命令:
git merge new-features
Note: If there are any uncommitted changes on your current branch, Git will not allow you to merge until all changes in your current branch have been committed. To handle those changes, you can either:
注意:如果当前分支上有任何未提交的更改,Git将不允许您合并,直到当前分支中的所有更改都已提交。 要处理这些更改,您可以:
Create a new branch and commit the changes
创建一个新分支并提交更改
git checkout -b new-branch-name
git add .
git commit -m "<your commit message>"
Stash them
藏起来
git stash # add them to the stash
git merge new-features # do your merge
git stash pop # get the changes back into your working tree
Abandon all of the changes
放弃所有更改
git reset --hard # removes all pending changes
Git Rebase (Git Rebase)
Rebasing a branch in Git is a way to move the entirety of a branch to another point in t