如何返回上一个提交,删除我在本地/公共存储库中发布的所有内容?

时间:2018-06-27 10:21:51

标签: git visual-studio-2017 commit ignore

我在本地仓库中。阶段+提交,而不是推送到服务器。现在,“主要提交”为import org.apache.spark.ml.classification.LogisticRegression import org.apache.spark.ml.tuning.{CrossValidator, ParamGridBuilder} import org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator // Instantiate a LogisticRegression object val lr = new LogisticRegression() // Instantiate a ParamGrid with different values for the 'RegParam' parameter of the logistic regression val paramGrid = new ParamGridBuilder().addGrid(lr.regParam, Array(0.0001, 0.001, 0.01, 0.1, 0.25, 0.5, 0.75, 1)).build() // Setting and fitting the CrossValidator on the training set, using 'MultiClassClassificationEvaluator' as evaluator val crossVal = new CrossValidator().setEstimator(lr).setEvaluator(new MulticlassClassificationEvaluator).setEstimatorParamMaps(paramGrid) val cvModel = crossVal.fit(training.toDF) // Getting the value of the 'RegParam' used to get the best model val bestModel = cvModel.bestModel // Getting the best model val paramReference = bestModel.getParam("regParam") // Getting the reference of the parameter you want (only the reference, not the value) val paramValue = bestModel.get(paramReference) // Getting the value of this parameter print(paramValue) // In my case : 0.001

我弄错了! ......

我想返回到上一次提交,同时返回到公共场所和本地仓库中的{strong> 。{p>

我该怎么办?尝试过4e4f27c554ee42e5fb7a0b62b6d921cbd05819c9,但是在本地存储库上,我仍然可以在“发出的提交”窗口(Visual Studio Git工具)中看到错误的“提交”,而且我不知道如何删除它。

什么是最好的方法?

1 个答案:

答案 0 :(得分:2)

您可以根据需要使用git revertgit reset:-

  • 使用git revert <commit_ID>-未删除还原的提交。相反,Git会创建一个新提交,其中包含的文件将还原为以前的状态。 因此,版本控制历史记录会向前移动,而文件状态会向后移动。
  • 使用git reset --hard <commit_ID>-Git丢弃存储库当前状态和目标提交之间的所有提交。然后分支似乎停止在您将HEAD重设到的提交处。尽管提交不再显示为分支历史的一部分,但不会将其删除。它们仍存储在Git中。

之后,将您的更改推送到远程(假设您的分支在此处和远程都称为master,而您的远程称为origin):-

# note this will hard reset your commit
git reset --hard <commit-hash>
# pushing changes to remote
git push -f origin master