gpt4 book ai didi

git - 你能把本地网络目录变成远程 git 存储库吗?

转载 作者:行者123 更新时间:2023-12-05 01:00:24 25 4
gpt4 key购买 nike

我在本地网络上有一个共享目录,用于文件存储和文件共享。是否可以将这样的目录转换为远程 git 存储库,以便我可以从本地 git 存储库推送到它?

最佳答案

是的,这是可能的。

您可以将共享目录视为远程存储库的本地副本。然后,您可以将更改从本地仓库推送到远程仓库。详细步骤如下:

1。创建远程仓库

您可以通过 git init --bare 在自己的服务器上设置远程 repo。

如果本地机器可以访问 github、bitbucket 等。你也可以在那里托管你的远程 repo。

2。如果您还没有设置,请设置本地 repo

在共享目录中,您应该将其视为本地 git repo。如果您在共享目录中没有本地 repo,请通过以下方式创建和提交:

# In the shared directory
git init
# If there has files which you do not want to commit in git repo, add a .gitignore to specify the files
git add .
git commit -m 'initial commit'

3。将远程仓库添加为本地仓库的远程

要将远程仓库添加为本地仓库的远程仓库并将更改推送到远程仓库,您可以使用以下命令:

git remote add origin <URL for the remote repo>
git push -u origin master

关于git - 你能把本地网络目录变成远程 git 存储库吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50375477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com