[英]Clean install on AWS EC2 from GIT
I have an app running on the AWS EC2 instance and something went wrong on the last update. 我有一个在AWS EC2实例上运行的应用程序,最近一次更新出了点问题。 I generally
ssh
to EC2 server and do a git pull
, where I have a remote repository. 我通常使用
ssh
到EC2服务器并执行git pull
,在那里我有一个远程存储库。
How can I do a clean install from my master repository? 如何从主存储库进行全新安装? Every time I do a git pull i get
you need to resolve your current index first
每次我执行git pull时,我
you need to resolve your current index first
Can I do a 我可以做一个
git reset --hard HEAD
git pull
from the remote repo on the EC2 instance ? 从EC2实例上的远程回购中?
I would definitely test this first in a non-production environment , but yes, a hard git reset
followed by git pull
would do the trick. 我肯定会在非生产环境中首先进行测试 ,但是是的,硬
git reset
和git pull
可以解决问题。
According to the documentation , git reset --hard HEAD
, does: 根据文档
git reset --hard HEAD
,它执行以下操作:
Resets the index and working tree.
重置索引和工作树。 Any changes to tracked files in the working tree since are discarded.
由于对工作树中跟踪文件的任何更改,都将被丢弃。
And then git pull
will pull the latest changes from your remote and apply them to your EC2 instance ( documentation ): 然后
git pull
将最新的更改从您的遥控器中git pull
并将它们应用于您的EC2实例( 文档 ):
Incorporates changes from a remote repository into the current branch
将来自远程存储库的更改合并到当前分支中
So yes, if you run git reset --hard HEAD
and then git pull
, you'll wipe out any local untracked changes and then get the latest from the remote. 因此,是的,如果您先运行
git reset --hard HEAD
,然后再执行git pull
,则将清除所有本地未跟踪的更改,然后从远程获取最新信息。 In fact, if your EC2 has already pulled the most recent commit, you won't need to git pull
at all. 实际上,如果您的EC2已经提取了最近的提交,则根本不需要
git pull
。
However, again, can't stress enough: if this is a production server, please first investigate the untracked changes to be sure that there isn't anything important that you'll regret losing ( git status
and git diff
will do) and then try the command, just to be sure, on a separate, non-production machine. 但是,再次强调的不够:如果这是生产服务器,请首先调查未跟踪的更改,以确保没有任何重要的事情会让您后悔(
git status
和git diff
会这样做),然后请确保在单独的非生产计算机上尝试该命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.