Git不快退拒绝(Git non-fast-forward rejected)
我觉得这个问题已经被问了很多次,但解决方案通常是“我删除了目录,并重新做了一个新的结帐工作。” 我做了一个提交和推送,但意识到我提到错误的票号在提交消息。 所以我看了一下SO的快速解决方案 ,最后在终端上输入以下内容:
$ git reset --soft HEAD^ $ git commit -m "... correct message ..."
唯一的问题是我收到以下错误消息:
To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
我正在使用git-flow模式,正在开发分支机构。 如何才能重新合并,让git再次开心?
I feel like this question has been asked many times, but the solution is typically "I deleted the directory and re-did my work with a fresh checkout." I did a commit and push but realized that I referred to the wrong ticket number in the commit message. So I looked on SO for a quick solution and ended up typing the following into the terminal:
$ git reset --soft HEAD^ $ git commit -m "... correct message ..."
The only problem is I am getting the following error message:
To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
I am using the git-flow model and am working on the develop branch. How can I merge things back in to make git happy again?
原文:https://stackoverflow.com/questions/5667476
最满意答案
在一般情况下,你不能,因为
@with_connection def spam(connection): # Do something
相当于
def spam(connection): # Do something spam = with_connection(spam)
这意味着“原始”垃圾邮件可能甚至不再存在。 一个(不太漂亮)的黑客就是这样的:
def with_connection(f): def decorated(*args, **kwargs): f(get_connection(...), *args, **kwargs) decorated._original = f return decorated @with_connection def spam(connection): # Do something spam._original(testcon) # calls the undecorated function
In the general case, you can't, because
@with_connection def spam(connection): # Do something
is equivalent to
def spam(connection): # Do something spam = with_connection(spam)
which means that the "original" spam might not even exist anymore. A (not too pretty) hack would be this:
def with_connection(f): def decorated(*args, **kwargs): f(get_connection(...), *args, **kwargs) decorated._original = f return decorated @with_connection def spam(connection): # Do something spam._original(testcon) # calls the undecorated function
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
传递给python装饰器中的另一个函数时的变量范围(Scope of variable when passed to another function in python decorators)[2022-05-13]
surround_with()函数返回另一个带闭包的函数对象: def surround_with(surrounding): """Return a function that takes a single argument and.""" def surround_with_value(word): return '{}{}{}'.format(surrounding, word, surrounding) return surround_with_value ... -
在一般情况下,你不能,因为 @with_connection def spam(connection): # Do something 相当于 def spam(connection): # Do something spam = with_connection(spam) 这意味着“原始”垃圾邮件可能甚至不再存在。 一个(不太漂亮)的黑客就是这样的: def with_connection(f): def decorated(*args, **kwargs): ...
-
你的装饰者如下: >>> def name(n): ... def decorator(fun): ... fun.name = n ... def wrapper(): ... return fun() ... return wrapper ... return decorator 您正在设置name属性以获得fun ,但您正在返回wrapper 。 换句话说,你用wrappe ...
-
我正在使用猪0.10.0。 当pig将模块用作UDF时,它将__name__设置为__lib__ 。 通常, __name__设置为模块的实际名称(减去.py)。 因此,您可以在if块内为outputSchema和outputSchemaFunction定义一些空装饰器。 就像是: myudfs.py #!/usr/bin/python if __name__ != '__lib__': def outputSchema(dont_care): def wrapper(func): ...
-
如果你的意思是关闭,你可以使用一个块: def foo puts 'before code' yield puts 'after code' end foo { puts 'here is the code' } If by function you mean closure, you could use a block: def foo puts 'before code' yield puts 'after code' end foo { puts 'here is ...
-
装饰者如何标记一个功能?(How do decorators mark a function?)[2022-03-26]
在decorate , foo是你装饰的功能(在这种情况下, hello )。 您可以将该函数存储在某个列表或字典中,因为它是一个普通对象。 例如: decorated_functions = [] def decorate(foo): def inner(): print("Some stuff 1") foo() print("Some stuff 2") decorated_functions.append(inner) re ... -
你应该阅读这个解释什么是python的装饰器。 我们与Python有关的“装饰者”与DecoratorPattern [...]并不完全相同。 Python装饰器是对Python语法的一种特定更改,它允许我们更方便地更改函数和方法(以及未来版本中可能的类)。 这支持DecoratorPattern的更易读的应用程序,但也支持其他用途。 因此,您将能够使用python的装饰器实现“经典”装饰器模式,但您将能够使用这些装饰器做更多(有趣;))事情。 在您的情况下,它可能看起来像: def applyToppin ...
-
自我在Python装饰(self in python decorators)[2022-05-03]
你不能从装饰器中访问self ,因为装饰器在定义函数的时候运行,并且当时还没有My_Class实例。 最好将函数列表作为类属性而不是实例属性。 然后,您可以将此列表作为参数传递给装饰器: def addToList(funcList): '''Decorator that adds the function to a given list''' def actual_decorator(f): funcList.append(f) return f ... -
看起来你忘了在装饰器的末尾返回新定义的函数: def Type_Check(correct_type): def new_function(old_function): def another_newfunction(arg): if(isinstance(arg, correct_type)): return old_function(arg) else: print " ...