如何将现有的非空目录转换为Git工作目录并将文件推送到远程存储库

筅森魡賤 提交于 2020-10-08 01:51:52

问题:

  1. I have a non-empty directory (eg /etc/something) with files that cannot be renamed, moved, or deleted. 我有一个非空目录(例如/ etc / something),其中包含无法重命名,移动或删除的文件。

  2. I want to check this directory into git in place. 我想将这个目录检查到git中。

  3. I want to be able to push the state of this repository to a remote repository (on another machine) using "git push" or something similar. 我希望能够使用“git push”或类似的东西将此存储库的状态推送到远程存储库(在另一台计算机上)。

This is trivial using Subversion (currently we do it using Subversion) using: 这很简单,使用Subversion(目前我们使用Subversion),使用:

svn mkdir <url> -m <msg>
cd <localdir>
svn co <url> .
svn add <files etc>
svn commit -m <msg>

What is the git equivalent? 什么是git等价物?

Can I "git clone" into an empty directory and simply move the .git directory and have everything work? 我可以“git clone”到一个空目录中,只需移动.git目录并使一切正常吗?


解决方案:

参考一: https://stackoom.com/question/DtXi/如何将现有的非空目录转换为Git工作目录并将文件推送到远程存储库
参考二: https://oldbug.net/q/DtXi/How-to-convert-existing-non-empty-directory-into-a-Git-working-directory-and-push-files-to-a-remote-repository
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!