好的,我在github上为一个项目做贡献.在GitHub上项目upstream,在github我的分叉回购是origin的,我local在我的电脑上回购.
git checkout -b feature
# Working on feature
git commit -a -m 'only commit on feature'
Run Code Online (Sandbox Code Playgroud)
然后我提交拉取请求
git push origin master
Run Code Online (Sandbox Code Playgroud)
审查拉取请求并且需要进行不相关的更改.其他人进行提交并合并upstream/master
现在我被upstream维护者要求"在主人之上重新提出我的拉动请求"
这是我的故事(插入法律和秩序音效).....
我没有对pull请求进行任何更改,它仍然在分支功能上进行相同的提交.
git checkout master
git fetch upstream
git checkout feature
git rebase master
=> "Current branch feature is up to date."
git push origin feature
=> "Everything up-to-date"
Run Code Online (Sandbox Code Playgroud)
我不明白.当upstream/master我推送拉动请求后,当我知道有人提交并合并时,这怎么可能origin/feature?
谁能告诉我在这种情况下应该采取什么样的正确程序?
从git书:
你会注意到那个合并中的短语"快进".因为您合并的分支所指向的提交直接位于您所在的提交的上游,所以Git将指针向前移动.换句话说,当你尝试将一个提交与可以通过遵循第一个提交的历史记录到达的提交合并时,Git通过向前移动指针来简化事情,因为没有不同的工作要合并在一起 - 这称为"快进".
但是,此"快进"的副作用是,如果您有一个具有多个提交的功能分支,则在合并回主服务器时将丢失该功能的历史上下文.换句话说,提交不会被组合在一起作为此功能的一部分.
with fast forward: x---x---x---x---x---x---x
without fast forward: x---x---x x---x---x---x
\x--x--x/
Run Code Online (Sandbox Code Playgroud)
手动方式是 git merge --no-ff
有谁知道如何将其设置为默认值?
我想我会想出一个灵活的方法来扩展Rails 3.x gem中的ApplicationController.
在我的宝石中lib/my_namespace/my_controller.rb,我有:
class MyNamespace::MyController < ApplicationController
before_filter :some_method
after_filter :another_method
def initialize
# getting classname of the subclass to use for lookup of the associated model, etc.
# and storing the model_class in an instance variable
# ...
end
# define :some_method, :another_method, etc.
# ...
private
attr_accessor :subclass_defined_during_initialize # etc.
# etc.
end
Run Code Online (Sandbox Code Playgroud)
但是当加载Gem时,app/controllers/application_controller.rb尚未加载,因此失败:
/path/to/rvm/gemset/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:
in `require': cannot load such file -- my_gem_name/application_controller (LoadError)
Run Code Online (Sandbox Code Playgroud)
作为一种解决方法,我在我的gem中定义了ApplicationController lib/gem_namespace/application_controller.rb:
class ApplicationController < ActionController::Base
end
Run Code Online (Sandbox Code Playgroud)
我假设即使我在那里定义它,它也会在我的Rails …
gem ruby-on-rails applicationcontroller ruby-on-rails-3 load-order
命令
git branch --set-upstream-to develop origin/develop
Run Code Online (Sandbox Code Playgroud)
导致错误
fatal: branch 'origin/develop' does not exist
Run Code Online (Sandbox Code Playgroud)
我不确定除了原点之外,这意味着什么不存在.这是否意味着它不存在于服务器或本地计算机上?
我是一个git新手,但我正在设置我的网站来处理部署与git作为学习git的手段.
git branch setup-deployment continuous-deployment git-branch
这是一个单独的帖子partial,作为feed部分的一部分呈现.所以它偏偏一部分.
一切都很好,除了time_ago_in_words线.错误是
ActionView::Template::Error:
undefined method `>' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)
它没有意义,因为feed_post它不是零.在错误出现之前渲染了3次.有一个created_at因为相同的帖子显示在不同的视图中,所以我知道它在数据库中.此外,如果我删除time_ago_in_words,只是feed_post.created_at让它工作正常.我很难过.
# shared/_feed_post.html.erb
<li>
<%= link_to gravatar(feed_post.user), feed_post.user %>
<span class="user">
<%= link_to feed_post.user.email, feed_post.user %>
</span>
<span class="post_text">
<%= feed_post.text %>
</span>
<span class="timestamp">
<%= time_ago_in_words(feed_post.created_at) %> #### Here is the trouble
</span>
</li>
Run Code Online (Sandbox Code Playgroud)
在这里,我使用集合渲染部分 @feed_posts
# shared/_feed.html.erb
<% if @feed_posts.any? %>
<ol class="posts">
<%= render partial: 'shared/feed_post', collection: @feed_posts %>
</ol>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这是控制器动作
def home
@feed_posts = current_user.feed …Run Code Online (Sandbox Code Playgroud) Control + 6或者Shift + Control + ^将在vim中切换当前文件和备用文件.它很有用,但我讨厌使用Control键并尽可能避免使用它.然而,尽管进行了搜索和实验,我似乎无法映射到我的领导者密钥.我认为问题出在数字键和插入符号上.任何人都有任何想法让这个工作?
提前致谢
这是我想在我的视图中访问的方法:
def current_user?(user)
user == current_user
end
Run Code Online (Sandbox Code Playgroud)
我基本上需要检查当前用户不能在视图中与朋友交朋友.
<% unless current_user?(@user) %>
<% if current_user.friendly?(@user)
<%= render 'unfriend' %>
<% else %>
<%= render 'friend' %>
<% end %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
Devise已经提供了current_user帮助方法.我在Rails项目中如何以及在何处添加此方法?
谢谢你的帮助
这是我正在试验的Rails CLI,并希望最终成为一个宝石.
任何人都有一个正则表达式或类似方法的想法,以确定当前工作目录是否是rails项目的rails根目录?
def check_current_directory
current_directory = Dir.getwd
if current_directory # How to determine if inside Rails root?
proceed
else
abort("You must be in the root of your Rails app to use this gem")
end
end
Run Code Online (Sandbox Code Playgroud)
任何帮助或想法表示赞赏