Android Studio 更新项目:Merge vs Rebase vs Branch Default [英] Android Studio Update Project: Merge vs Rebase vs Branch Default

查看:129
本文介绍了Android Studio 更新项目:Merge vs Rebase vs Branch Default的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这看起来多余,我深表歉意,因为我知道关于 Merge 与 Rebase 有相当多的问题,但似乎也没有任何涉及分支默认"的问题.

Apologies if this seems redundant as I know there are fair amount of questions regarding Merge vs Rebase, but there doesn't seem to be any that throw in 'Branch Default' as well.

您有一个案例,其中有多人同时处理某件事(即 Android Studio 中的 Android 应用).如果有人推送到 master 分支并且您想拉入新的 master 以便它不会覆盖您仍在工作并且尚未提交并推送到 master 的工作,那么更新项目/拉取的最佳选择是什么?单击更新项目"时,Android Studio 会列出合并"、变基"和分支默认值".从听起来像,我想做Rebase"(后跟Merge"?),但我不完全确定.

You are given a case where you have multiple people working on something (i.e. an Android app in Android Studio) concurrently. What is the best option to update project/pull if someone pushes to the master branch and you want to pull in the new master such that it doesn't overwrite the work you are still working on and have yet to commit and push to master? Android Studio lists 'Merge' 'Rebase' and 'Branch Default' when clicking 'Update Project'. From what it sounds like, I would want to do 'Rebase' (followed by 'Merge'?), but I'm not entirely sure.

推荐答案

Stashing

这里的关键是您有要保存的未提交工作.在尝试合并任何内容之前,您应该隐藏您的更改以保存您的未提交的更改并清理您的工作目录.

The key here is that you have uncommitted work that you want to save. Before trying to merge anything in, you should stash your changes to save your uncommitted changes and clean your working directory.

运行 git stash 以存储您的更改.然后,您应该能够毫无问题地拉取更改.

Run git stash to stash your changes. You should then be able to pull the changes without any issues.

成功拉取后,您可以执行 git stash apply 以重新应用拉取前所做的更改.

After you have successfully pulled, you can do a git stash apply to re-apply the changes you had made prior to the pull.

合并和变基

只有当您只有未提交的更改时,才可以存储您的更改.如果在某个时候您提交了但没有推送,您将需要重新设置基准或合并.

Stashing your changes only works if you only have uncommitted changes. If at some point you committed but didn't push you will need to either rebase or merge.

这篇 StackOverflow 帖子 提供了一些关于差异的重要信息.

This StackOverflow post has some great information on the differences.

总的来说,合并更容易,但有些人认为合并提交会污染"git历史.

In general, merging is easier, but some believe that it "pollutes" the git history with merge commits.

变基需要额外的工作,但由于您没有合并提交,它基本上会使合并不可见.

Rebasing requires additional work, but since you don't have a merge commit it will essentially make the merge invisible.

同样,在您的情况下,您不需要合并或变基.简单地藏起来,拉,然后应用藏起来,一切都会好起来的.

Again, in your case you shouldn't need to merge or rebase. Simply stash, pull, then apply the stash and it should all be good.

这篇关于Android Studio 更新项目:Merge vs Rebase vs Branch Default的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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