将 GIT 存储库源的副本与存储库链接
GIT 存储库中有一个项目,该项目安装在生产服务器中,但 GIT 未初始化。有些人上个月在生产服务器的源中编辑了文件,但那里没有 GIT。我尚未创建存储库或在服务器上安装,但现在我想在生产服务器中安装 GIT,并将现有源链接到 GIT 存储库,并将现有源的更改提交到 GIT 存储库。
我尝试将生产服务器的文件复制到 mi PC 的本地目录中,然后:
git init
git remote add origin https://.....git
当我运行 git status 时,它返回:
On branch master
No commits yet
Untracked files:
...
...
我期望只出现不同的文件,但绝对会出现所有文件未跟踪的红色。
我怎么做到这一点?
提前致谢
There is a proyect in a GIT repository and this proyect is installed in a production server but GIT is not initialized. Some people have edited files in the source of the production server last months but no GIT there. I have not created the repository or installed on the server but now I want to install GIT in the production server and link the existing source to the GIT repository and commit the changes of the existing source to the GIT repository.
I've tried to copy the files of the production server in a local directory of mi PC and then:
git init
git remote add origin https://.....git
When I run git status
it returns:
On branch master
No commits yet
Untracked files:
...
...
I expected only the distinct files to appear but absolutely all files appear untracked in red.
How I do that?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这会很棘手。基本方法可能是执行 git clone ... 来获取存储库的当前状态,然后只需将所有文件替换为生产服务器文件的副本。
但是,这可能会将文件恢复到您不希望恢复的旧版本(除了包括您实际想要的更改之外)。我不知道你的存储库有多大,所以我不知道这可能是一个多大的问题。对更改进行仔细的代码审查可能会起作用。
完整步骤:
此时,您可以向主分支发出拉取请求,并仔细代码审查您看到的任何更改。您最终可能只想引入您看到的一些更改。祝你好运。
This is going to be tricky. A basic method might be to do
git clone ...
to get the current state of the repository, then simply replace all files with your copy of the production server files.However, this will likely revert files to older versions that you don't want reverted (in addition to including the changes you actually want). I don't know how large your repository is, so I don't know how much of a problem this may be. Careful code review of the changes may work.
Full steps:
At this point you can make a pull request into your master branch and carefully code review any changes that you see. You will likely end up wanting to pull in just some of the changes that you see. Best of luck.