如何还原到.env文件可用的先前版本 [英] how do I restore to a previous version wherein the .env file is available

查看:68
本文介绍了如何还原到.env文件可用的先前版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是git中的一个newb的一个愚蠢的问题,用git搞砸了很多,但是现在我想知道是否可以在应用程序中还原到以前的版本,因为我的.env环境配置文件已经消失了我当前的主分支,我确实将其他分支与此分支合并了.我知道我在chat-feature分支上做了最新工作,几乎100%的应用程序都在那儿,因为聊天部分和该应用程序的付款功能都在那儿,但是当我在那儿结账时,它甚至无法工作,我我想知道如何才能返回到之前的提交.当我使用git log时,我想回到该特定版本.

Just a dumb question from just a newb in git, Messed up alot with git, but now I was wondering if how can I restore to a previous version in the application, since my .env environment configuration file is now gone in my current master branch, I did merge my other branch with this one. I knew I made my latest work on my chat-feature branch, pretty much the 100% of the application was there, since the chat part and the payment feature of the application was there but when I checkout there, its not even working, I was wondering how can I go back to that previous commit that I made. When I git log I want to be back to this specific version.

推荐答案

还原+ push --force

我不推荐任何需要--force的内容,但对于您而言,这可能是最干净的解决方案.如果您与其他人共享您的代码,请不要遵循此操作-您正在更改历史记录.

Restore + push --force

I don't like to recommend anything that requires --force but in your case it may be the cleanest solution. If you shared your code with others, don't follow this - you're changing history.

让我们使masterchat-feature.

  1. 以防万一,在存储驱动器上制作一份回购副本.
  2. git checkout master
  3. git checkout -b master_copy(可选,但是让我们将master中当前拥有的内容存储为新分支;如果倒带太多,这将使它易于使用)
  4. git checkout chat-feature
  5. 检查这就是您想要的master外观.
  6. git log -n 1
  7. 复制提交ID
  8. git checkout master
  9. git reset --hard <commit-id>
  10. 再次检查一切正常,这就是您想要的.
  11. git push --force
  1. Make a copy of the repo (on your drive), just in case.
  2. git checkout master
  3. git checkout -b master_copy (optional, but let's store what we currently have in master as a new branch; this will make it easy to use it if rewind too much)
  4. git checkout chat-feature
  5. Check that this is what you want master to look like.
  6. git log -n 1
  7. Copy the commit id
  8. git checkout master
  9. git reset --hard <commit-id>
  10. Double check that things work and that's what you want.
  11. git push --force

这篇关于如何还原到.env文件可用的先前版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆