如何还原到.env文件可用的先前版本 [英] how do I restore to a previous version wherein the .env file is available
问题描述
只是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.
让我们使master
像chat-feature
.
- 以防万一,在存储驱动器上制作一份回购副本.
-
git checkout master
-
git checkout -b master_copy
(可选,但是让我们将master中当前拥有的内容存储为新分支;如果倒带太多,这将使它易于使用) -
git checkout chat-feature
- 检查这就是您想要的
master
外观. -
git log -n 1
- 复制提交ID
-
git checkout master
-
git reset --hard <commit-id>
- 再次检查一切正常,这就是您想要的.
-
git push --force
- Make a copy of the repo (on your drive), just in case.
git checkout master
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)git checkout chat-feature
- Check that this is what you want
master
to look like. git log -n 1
- Copy the commit id
git checkout master
git reset --hard <commit-id>
- Double check that things work and that's what you want.
git push --force
这篇关于如何还原到.env文件可用的先前版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!