[英]Git, someone deleted my .git directory, and committed everything into a larger project that I don't want to start tracking locally
I've been working on a WordPress theme for a while, tracking it on my own repo back and forth, and pulling from the remote server through ssh. 我一直在研究WordPress主题已有一段时间,在我自己的仓库中来回跟踪它,并通过ssh从远程服务器中提取。
Yesterday, someone from the company initialized the whole project tree as a repo, and deleted the .git
directory of the directory I was working on. 昨天,该公司的某人将整个项目树初始化为一个存储库,并删除了我正在处理的目录的.git
目录。
Now, I have some new commits I want to take to the server, but the remote repository is now different than mine, and also other people have worked and made commits on the new (larger) repo. 现在,我有一些要提交到服务器的新提交,但是远程存储库现在与我的不同,并且其他人也已经在新的(更大)存储库上进行了提交工作。
What can I do in this situation in order to keep working only on the particular directory I was working on, and be able to synchronize my work correctly? 在这种情况下,我该怎么办才能只在我正在处理的特定目录上工作,并能够正确同步我的工作?
I have thought of two alternatives: 我想到了两种选择:
1.- Copy my .git
directory into my working directory on the remote server. 1.-将我的.git
目录复制到远程服务器上的工作目录中。 Then keep working as normal. 然后继续正常工作。 2.- Start using rsync
to move my changes onto the server. 2.-开始使用rsync
将我的更改移到服务器上。
I'm a bit lost here so any help is appreciated. 我在这里有点迷路,因此不胜感激。 Thanks 谢谢
Assuming your work tree is intact, you can try 假设您的工作树是完整的,则可以尝试
Take a backup of your current clone / folder. 备份当前克隆/文件夹。
In current folder 在当前文件夹中
git initStash you changes and add your server remote as 存储您的更改并将远程服务器添加为
git remote add neo-origin ssh://example-server/project.git git remote add neo-origin ssh://example-server/project.git
Git fetch and checkout master (or whichever) branch relative to new-origin 相对于新来源的Git提取和结帐主节点(或任意一个)分支
Lastly apply the stash and push it to remote. 最后,应用存储并将其推送到远程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.