Guy*_*ood 5 git version-control
我在本地网络上有一个共享目录,用于文件存储和文件共享目的。是否可以将这样的目录转换为远程 git 存储库,以便我可以从本地 git 存储库推送到它?
是的,有可能。
\n\n您可以将共享目录视为远程存储库的本地副本。然后您可以将更改从本地存储库推送到远程存储库。详细步骤如下:
\n\n您可以通过在您自己的服务器上设置远程存储库git init --bare。
如果本地计算机可以访问 github、bitbucket 等,您还可以在那里托管您的远程存储库。
\n\n在共享目录中,您应该将其视为本地 git 存储库。如果共享目录中没有本地存储库,请通过以下方式创建并提交:
\n\n# In the shared directory\ngit init\n# If there has files which you do not want to commit in git repo, add a .gitignore to specify the files \ngit add .\ngit commit -m 'initial commit'\nRun Code Online (Sandbox Code Playgroud)\n\n要将远程存储库添加为本地存储库的远程存储库并将更改推送到远程存储库,您可以使用以下命令:
\n\ngit remote add origin <URL for the remote repo>\ngit push -u origin master\nRun Code Online (Sandbox Code Playgroud)\n