当我键入git push origin master
时,从git显示以下错误消息:
To https://github.com/farrasdoko/RumahSakit.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/farrasdoko/RumahSakit.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
然后,我输入git fetch origin
,git merge origin master
和git pull origin master
git中显示以下错误消息:
From https://github.com/farrasdoko/RumahSakit
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
如何推动它?
答案 0 :(得分:3)
hint: Updates were rejected because the tip of your current branch is behind
通常发生这种情况时,您真正想做的就是将origin/master
中的其他提交添加到您自己的提交之前的分支 中。 您可以使用rebase
命令来做到这一点:
git rebase origin/master
这会将新的提交从origin
拉到您的分支中,然后在顶部添加您自己的新提交,以便您的提交是最新的。重新设定基准时,您可能会遇到一些冲突。发生这种情况时,git
将停止并告诉您解决冲突;之后,您应该git add
受影响的文件,然后git rebase --continue
。或者,如果您决定不知道如何处理该问题,则可以git rebase --abort
,分支将返回到git rebase
命令启动之前的状态。
git rebase
是一个功能强大的命令,可以使您的分支快速混乱,因此请谨慎操作,但不要担心。适用标准计算建议:如果不确定,请在执行任何操作之前先备份您的工作。幸运的是,只需创建一个新分支作为备份(git checkout -b my_backup_branch
),然后再切换回您的工作分支就很容易了。
答案 1 :(得分:1)
两种方法。我认为您已经签出了硕士学位。
1。
def calculator():
num1 = float(input("First number: "))
operator = input("Choose: +, -, /, or *")
num2 = float(input("Second number: "))
num1 = int(num1) if num1.is_integer() else num1
num2 = int(num2) if num2.is_integer() else num2
add = (num1 + num2)
subtract = (num1 - num2)
divide = (num1 / num2)
multiply = (num1 * num2)
if operator == "+" and add % 1 == 0:
print(num1, "+", num2, "is equal to:", int(add))
elif operator == "+" and not add % 1 == 0:
print(num1, "+", num2, "is equal to:", add)
elif operator == "-" and subtract % 1 == 0:
print(num1, "-", num2, "is equal to:", int(subtract))
elif operator == "-" and not subtract % 1 == 0:
print(num1, "-", num2, "is equal to:", subtract)
elif operator == "/" and divide % 1 == 0:
print(num1, "/", num2, "is equal to:", int(divide))
elif operator == "/" and not divide % 1 == 0:
print(num1, "/", num2, "is equal to:", divide)
elif operator == "*" and multiply % 1 == 0:
print(num1, "*", num2, "is equal to:", int(multiply))
elif operator == "*" and not multiply % 1 == 0:
print(num1, "*", num2, "is equal to:", multiply)
calculator()
然后解决冲突
git merge origin/master --allow-unrelated-histories
OR
2.
git add -A .
git commit -m "Commit message"
git push origin master