Github使用記錄(windows環境)
阿新 • • 發佈:2018-12-09
根據實際需要,需要將本地的專案放到github上;
首先在本地已有的專案下,用git bash命令進入,然後執行:ssh-keygen -t rsa -C "你的遠端git郵箱地址";
執行完之後找到C:/User/使用者名稱/.ssh/資料夾,其中有兩個檔案,一個是id_rsa是私鑰,id_rsa.pub是公鑰,複製公鑰裡面的內容,到github上找到setting,中的ssh……Key,然後將複製的內容考進去,生成對應的SSH Key即可;
此時已經可以與github進行ssh通訊了;
在本地倉庫執行:
git init // 通過命令 git init 把這個目錄變成git可以管理的倉庫 git add . // 把檔案新增到版本庫中,使用命令 git add .新增到暫存區裡面去,不要忘記後面的小數 // 點“.”,意為新增資料夾下的所有檔案(夾)。 git commit -m "first commit" // commit到本地倉庫 git remote add origin "遠端倉庫的地址" // 與遠端倉庫進行關聯 git push -u origin master // 將本地倉庫的內容push 到遠端倉庫
注:1.如果在進行關聯遠端倉庫的時候,提示:
Permission denied (publickey) fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
說明很有可能就是你沒有配置ssh許可權,需要進行配置ssh許可權:ssh-keygen -t C rsa "你的郵箱地址";然後按照之前的步驟一步步配置SSH key;
2. 在關聯遠端倉庫的時候提示:fatal: remote origin already exists.
需要刪除遠端的倉庫,然後再執行相同的關聯語句;
git remote rm origin;