Git Pull与Git Rebase [英] Git Pull vs Git Rebase

查看:68
本文介绍了Git Pull与Git Rebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Git的菜鸟,正在尝试了解git pullgit rebase之间的区别.有人可以提供一个示例说明何时使用哪个选项,因为我觉得这两个选项具有相同的用途.

I'm a noob in Git, and trying to learn the difference between git pull vs git rebase. Can someone provide an example when to use which option since I feel that both serve the same purpose.

推荐答案

git pullgit rebase不可互换,但它们紧密相连.

git pull and git rebase are not interchangeable, but they are closely connected.

git pull从远程获取当前分支的最新更改,并将这些更改应用于分支的本地副本.通常,这是通过合并完成的,即将本地更改合并到远程更改中.因此git pullgit fetch & git merge类似.

git pull fetches the latest changes of the current branch from a remote and applies those changes to your local copy of the branch. Generally this is done by merging, i.e. the local changes are merged into the remote changes. So git pull is similar to git fetch & git merge.

重定基础是合并的替代方法.它没有创建将两个分支合并的新提交,而是将其中一个分支的提交移到了另一个分支的顶部.

Rebasing is an alternative to merging. Instead of creating a new commit that combines the two branches, it moves the commits of one of the branches on top of the other.

您可以使用重新设置而不是合并(git pull --rebase)拉动.您所做的本地更改将以远程更改为基础,而不是与远程更改合并.

You can pull using rebase instead of merge (git pull --rebase). The local changes you made will be rebased on top of the remote changes, instead of being merged with the remote changes.

Atlassian有一些很棒的有关合并与重新设置基础的文档.

Atlassian has some excellent documentation on merging vs. rebasing.

这篇关于Git Pull与Git Rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆