简体   繁体   English

Git,有人删除了我的.git目录,并将所有内容提交到了一个我不想在本地开始跟踪的较大项目中

[英]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 init
Stash 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.

相关问题 Git恢复文件本地删除尚未提交 - Git restore files locally deleted not committed yet 我想列出某人的 git commit ,但我不知道此后或之后的 git 命令格式 - I want to list someone 's git commit ,but I don't know the git command formate of since or after Git删除了我所有的更改,然后才提交 - Git Deleted all my changes before I committed them 我不想在 .git/config 中缓存我的帐户 - I don't want to cache my account in .git/config git显示了一个分支“ 5落后2落后”。 我想保留提交,但不在乎跟踪它 - git shows a branch “5 ahead 2 behind”. I want to keep the commit, but don't care about tracking it 合并 git 分支,其中文件在一个分支上被删除,我不希望它们成为 - Merge git branches where files were deleted on one branch and I don't want them to be 我不小心在我的第一个 Git 推送中提交了我的项目文件夹。 但我根本不想在 Git 中有父文件夹。 我能做些什么来解决这个问题? - I accidentally commited my project folder in my first Git push. But I don't want to have a parent folder at all in Git. What can I do to fix this? 我不想要的git - git where I don't want it 我已经在本地提交了对git的更改,现在想在另一台计算机上解决此问题而不需要检入master - I have committed changes to git locally and now want to work off this on another computer without checking in to master sourcetree-git:我想要一个头脑 - sourcetree - git :I want a committed in head
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM