【发布时间】:2014-07-14 17:43:02
【问题描述】:
我需要在app/views/cgi_testing_seeds/index.html.haml中提取一段sn-p代码,
形成这个提交'77df270',因为它应该由其他提交拥有。
恢复或回滚到那个提交'77df270'非常复杂, 然后再次重做所有剩余的提交,
例如如果我只想还原CgiTestingSeedsController.rb中index method的代码,
并将其添加到提交中 4b733c5 ,如何?
或者把方法的代码提取出来,保持在staged状态,怎么办?
在 Git 中更容易做到这一点。
简短日志
4b733c5 - (HEAD, feature/testing_seeds_model) Scaffold:Testing seed and generate testing data via 'faker gem' (7 minutes ago) <poc7667>
2fd8204 - (develop) Merge branch 'hotfix/wrong_column_names_in_CGIparamters' into develop (4 days ago) <poc7667>
052e2ff - Remove 'name' in 'cgi_attributes' and fix wrong name for 'default_value' (4 days ago) <poc7667>
77df270 - Scaffold: CgiTestingSeed (2 days ago) <poc7667>
提交 77df270 中更改的文件
77df270 - Scaffold: CgiTestingSeed (2 days ago) <poc7667>
app/assets/javascripts/cgi_testing_seeds.js.coffee
app/controllers/cgi_testing_seeds_controller.rb
app/helpers/cgi_testing_seeds_helper.rb
提交 77df270 中的 CgiTestingSeedsController.rb
class CgiTestingSeedsController < ApplicationController
before_action :set_cgi_testing_seed, only: [:show, :edit, :update, :destroy]
# GET /cgi_testing_seeds
# GET /cgi_testing_seeds.json
def index
@cgi_testing_seeds = CgiTestingSeed.all
end
# GET /cgi_testing_seeds/1
# GET /cgi_testing_seeds/1.json
def show
end
【问题讨论】:
-
你真正想做的事情很模糊,但你可能需要挑选。 kernel.org/pub/software/scm/git/docs/git-cherry-pick.html.
-
@CommuSoft 我更新了,希望可以更清楚。
-
为什么不复制粘贴?
-
@Basilevs 但我应该从提交中删除片段代码,对吧?因为它不应该在那里发生。
-
如果你想删除一部分代码,你应该这么说。 “提取”是一个不好的措辞。
标签: git