简体   繁体   English

本地提交后的Git pull

[英]Git pull after local commit

I am new to git. 我是git的新手。 I have a few local commits but I want to pull the latest code from the repository and don't yet want to push mine. 我有一些本地提交,但我想从存储库中提取最新的代码并且还不想推送我的。 However git pull, creates unnecessary merges. 然而git pull,会创建不必要的合并。 What is the right way to do this ie update your local repository without losing the changes. 正确的方法是什么,即更新本地存储库而不会丢失更改。

The tool you are looking for is git rebase , though you should look at the documentation about that before you start using it. 您正在寻找的工具是git rebase ,但在开始使用之前,您应该查看有关该文档的文档。 It is also generally good practice to do development in a local branch to reduce the overhead of this sort of operation. 通常,在本地分支中进行开发以减少此类操作的开销也是一种好习惯。

When you are comfortable, you can use git pull --rebase to use rebase rather than merge to resolve differences after the pull -- but, do read the docs first, because this can lose data or cause headaches if misused. 当你感到舒服时,你可以使用git pull --rebase来使用rebase而不是merge来解决拉动后的差异 - 但是,请先阅读文档,因为如果误用,这会丢失数据或引起麻烦。 It is a useful but dangerous tool. 这是一个有用但危险的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM