我有一个功能分支和一个主分支。
Master 分支已经发展,我的意思是让这些更新尽可能少地与 master 分支分开。
所以我git pull在两个分支中,git checkout feature/branch最后 git rebase master .
现在在这里,我要么希望一切顺利,要么在继续 rebase 之前需要解决冲突,直到所有主提交都成功地重新应用到功能分支上为止。
现在在我的情况下真正发生的是我不明白的事情:
$>git rebase master
First, rewinding head to replay your work on top of it...
Applying: myFirstCommitDoneOnTheBranch
Applying: myOtherCommitDoneOnTheBranch
$>git status
On branch feature/branch
Your branch and 'origin/feature/feature' have diverged,
and have 27 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
$>git pull
*load of conflicts*
Applying消息指的是:什么应用了哪个版本的提交?
最佳答案
tl;博士 您应该同时更新 master和 feature与 git pull和 git pull --rebase 之前 rebase feature顶部 master . 没有必要做 git pull 后 您已重新定位您的 feature顶部的分支 master .
以您当前的工作流程,原因 git status告诉你这个:
Your branch and 'origin/feature' have diverged, and have 27 and 2 different commits each, respectively.
feature分行现在有 25 无法从 origin/feature 访问的新提交(因为它们来自 master 的 rebase )加上 2 可从 origin/feature 访问的提交但有不同的提交 ID。这些提交包含相同的更改(即它们是补丁等效的),但它们具有不同的 SHA-1 哈希值,因为它们基于 origin/feature 中的不同提交而不是您在本地存储库中重新基于它们的那个。git pull在 master :A - B - C (master)
\
D - E (feature)
git pull , master得到提交 F :A - B - C - F (master, origin/master)
\
D - E (feature)
feature顶部 master , 适用 D和 E :A - B - C - F (master, origin/master)
\
D - E (feature)
origin/feature仍然基于提交 C :A - B - C - F (master, origin/master)
\ \
\ D' - E' (feature)
\
D - E (origin/feature)
git status在 feature , Git 会告诉你你的 feature分支已与 origin/feature 分道扬镳与 3 ( F , D' , E' ) 和 2 ( D , E ) 分别提交。Note that
D'andE'contain the same changes asDandEbut have different commit IDs because they have been rebased on top ofF.
git pull在两个 master和 feature rebase 前 feature在 master .但是,由于您可能已经提交了 feature您还没有推送到 origin ,你会想要做:git checkout feature && git pull --rebase
origin/feature 之间创建 merge 提交和您本地的 feature .git status报告 feature和 origin/feature rebase 后出现分歧是因为 rebase 为 feature 带来了新的提交。 ,此外它还重写了之前推送到 origin/feature 的提交。 .A - B - C - F (master)
\
D - E (feature, origin/feature)
feature和 origin/feature指向同一个提交 E ——换句话说,它们处于“同步”状态。 rebase 后 feature顶部 master ,历史将如下所示:A - B - C - F (master)
\ \
\ D' - E' (feature)
\
D - E (origin/feature)
feature和 origin/feature已经发生分歧,它们的共同祖先被提交 C .这是因为 feature现在包含新的提交 F来自 master加D'和 E' (读作“D 素数”和“E 素数”)是提交 D和 E应用在 F 之上.即使它们包含相同的更改,Git 也会认为它们不同,因为它们具有不同的提交 ID。同时,origin/feature仍然引用 D和 E .git pull在 feature这就是会发生的事情:A - B - C - F (master)
\ \
\ D' - E'- M (feature)
\ /
D - E - (origin/feature)
git pull是否git fetch + git merge ,这将导致创建 merge 提交 M ,其 parent 是 E'和 E .git pull --rebase (即 git fetch + git rebase )然后 Git 会:feature提交 C (feature 和 origin/feature 的共同祖先) D和 E来自 origin/feature F , D'和 E' D'和 E'包含与 D 相同的更改和 E , Git 只会丢弃它们,导致历史看起来像这样:A - B - C - F (master)
\
D - E - F' (feature)
^
(origin/feature)
F , 以前可从 feature 访问, 被应用在 origin/feature 之上导致 F' .此时,git status会告诉你:Your branch is ahead of 'origin/feature' by 1 commit.
F' .
关于git pull *after* git rebase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42861353/
ActiveRecord用于在每次调用保存方法时调用after_save回调,即使模型没有更改并且没有生成插入/更新查询也是如此。这实际上是默认行为。在大多数情况下这没问题。但是一些after_save回调对模型是否实际保存的事情很敏感。有没有办法确定模型是否实际保存在after_save中?我正在运行以下测试代码:classStage 最佳答案 ActiveRecordusetocallafter_savecallbackeachtimesavemethodiscalledevenifthemodelwasnotchangedan
我有一个(我认为)相对简单的has_many:through与连接表的关系:classUser:user_following_thing_relationshipsendclassThing:user_following_thing_relationships,:source=>:userendclassUserFollowingThingRelationship还有这些rspec测试(我知道这些不一定是好的测试,这些只是为了说明正在发生的事情):describeThingdobefore(:each)do@user=User.create!(:name=>"Fred")@thing=
在Test::Unit中的ruby单元测试断言失败后,在执行teardown之前,是否有一些简洁优雅的方法来立即执行我的代码?我正在做一些自动化的GUI测试,并希望在出现问题后立即截图。 最佳答案 如果您使用的是1.9,请不要使用Test::Unit::TestCase作为您的基类。对其进行子类化并覆盖#run_test以进行救援,截取屏幕截图并重新提出:classMyAbstractTestCase或者,我认为这实际上是最简洁的方法,您可以使用before_teardownHook:classMyTestCase这不适用于1.
我想使用after_save回调将updated_by列设置为current_user。但是current_user在模型中不可用。我应该怎么做? 最佳答案 需要在controller中处理。首先在模型上执行保存,然后如果成功则更新记录字段。例子classMyController另一种选择(我更喜欢这个)是在您的模型中创建一个自定义方法来包装逻辑。例如classRecord 关于ruby-on-rails-after_save回调将updated_by列设置为current_user,我
我们的RSpec测试套件中有相当多的测试。目录结构看起来像-spec/truncation/example1_spec.rbexample2_spec.rb...transaction/example1_spec.rbexample2_spec.rb...我想在transaction/文件夹中的所有规范文件运行之前恢复测试数据库转储,并在所有测试完成后将其清空。有办法吗?有before(:suite)和after(:suite)Hook,但它们适用于单个规范文件。有没有办法在RSpec中为目录提供前后Hook? 最佳答案 你在使用R
我使用命令rakedoc:app为我的Rails应用程序生成一些基本文档。它在过去一直运行良好。昨天我通过应用程序从Ruby1.9.3升级到2.1.1,从Rails3.2升级到4.1。该应用程序一切正常,所以几周后我第一次重新生成文档,但失败了。我运行上面的命令并收到以下错误消息:rakeaborted!Don'tknowhowtobuildtask'README.rdoc'/home/vagrant/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in`eval'/home/vagrant/.rvm/gems/ruby-2.1.1/
我想在用户提交电子邮件后redirect_toslider_path。当前,仅显示成功消息而没有重定向。这是代码:classSplash::SubscribersController{:success=>success,:message=>message}.to_json}endendend 最佳答案 只需替换这部分代码:ifsuccessflash[:success]=messageredirect_toslider_pathelseflash[:error]=messageendredirect_toroot_path用这个:i
我知道上面的问题是很常见的问题。我已经阅读了关于这个主题的多篇文章。但是我没有得到任何解决方案。我已经在本地安装了rvm。我们已经有了安装文件。所以进入文件夹并运行安装命令。$./install然后我检查了Users主文件夹中的./rvm文件夹$cd~/.rvm文件夹存在。至此安装成功。现在我在命令行输入rvm$rvm我正在低于异常$rvm-sh:rvm:commandnotfound在阅读了stackoverflow中有关此问题的多篇文章后,我了解到我必须在.bash_profile中添加以下行,因为我使用的是MacOSX10.7.3[[-s"$HOME/.rvm/scripts/r
相关编码:http://pastebin.com/EnLJUJ8GclassTask我正在制作一个小型任务应用程序。每个任务都分配到一个房间。添加任务后,我想使用回调来检查同一房间中在我刚添加的任务之前和之后是否有任务(尽管我的代码现在只处理一种边缘情况)。所以我决定使用after_create(因为用户在编辑它时会手动检查它,因此不是after_save)所以我可以使用两个范围和一个类方法来查询当天、房间里的任务,以及按时间订购。然后我在数组中找到对象并开始使用if语句。我必须明确地保存对象。有用。但我这样做感觉很奇怪。我不太有经验(第一个应用程序),所以我不确定这是不受欢迎的还是惯
我使用的是rails4.0.5、rspec2.14.1、capybara2.2.1、capybara-webkit1.1.0和database_cleaner1.2.0。我在以下功能测试中看到一些奇怪的行为(模拟用户查看帖子评论,将鼠标悬停在图标上以显示菜单,然后单击菜单项删除评论):let(:user){create(:user)}let(:post){create(:post,author:user)}let!(:comment){create(:comment,post:post,author:user)}...it"candeleteacomment"doassert(page