[英]Can you turn a local network directory into a remote git repository?
我在本地網絡上有一個共享目錄,用於文件存儲和文件共享。 是否可以將這樣的目錄轉換為遠程 git 存儲庫,以便我可以從本地 git 存儲庫推送到它?
是的,這是可能的。
您可以將共享目錄視為遠程存儲庫的本地副本。 然后您可以將更改從本地存儲庫推送到遠程存儲庫。 詳細步驟如下:
你可以通過git init --bare
在你自己的服務器上設置遠程git init --bare
。
如果本地機器可以訪問 github、bitbucket 等,你也可以在那里托管你的遠程倉庫。
在共享目錄中,您應該將其視為本地 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'
要將遠程倉庫添加為本地倉庫的遠程倉庫並將更改推送到遠程倉庫,您可以使用以下命令:
git remote add origin <URL for the remote repo>
git push -u origin master
linux 上本地目錄的 url 使用:'file' 然后是 3 個斜杠,例如git remote add origin file:///home/mark/remote_repo
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.