簡體   English   中英

GIT SSH連接到服務器並在其中創建存儲庫並添加文件

[英]GIT SSH Connection to server and create repository there and add files

我需要git幫助。 我有一個服務器,用戶名和parol。 我與ssh成功連接,但無法添加文件。 當我想使用git add使用bash添加文件(從我的本地PC)時,重試無法找到文件路徑或路徑不存在。 我認為它正在搜索服務器中的文件或目錄。

謝謝。

使用Git,您不必直接在服務器上創建存儲庫。 相反,你

  • 在本地創建一個存儲庫( git init ),
  • 向其中添加文件,通常包括兩個步驟:
    • 階段文件( git add
    • 將暫存的文件提交到本地存儲庫( git commit
  • 向其分配遠程服務器的存儲庫( git remote add
    • 注意1:我假設您已經以某種方式創建了遠程存儲庫-請參考服務器說明。
    • 注意2:您在服務器上創建一個空的存儲庫。
  • 將本地存儲庫上傳到遠程存儲庫( git push

示例腳本:

$ cd your_local_project_dir/              # Get into your your project directory

$ git init                                # Initialize a local repository

$ git add --all                           # Stage all files from your local project
                                          # directory for commit (note this is not
                                          # adding to the repository yet, it's just
                                          # "prepare them to add into the repo")

$ git commit -m "Initial commit"          # Add the staged files to the local repository

$ git remote add origin https://server.com/user/project_name.git
                                          # Link the local repository to a remote one

$ git push -u origin master               # Upload you local repository data to the
                                          # remote one

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM