我對 Git/Github 很陌生。我正在嘗試將我的程式/網站上傳到 Github,這樣我就可以將它上傳到 Heroku。
我嘗試了很多不同的東西,但我堅持了一個多星期......據我所知,這樣做的方法是:
git init
git add .
git commit -m 'initial commit
我得到的結果是:
git init>Reinitialized existing Git repository in /Users/username/test/website/.git/
git add .>error: 'website/' does not have a commit checked out fatal: adding files failed
git commit -m 'initial commit>
Untracked files:
(use "git add <file>..." to include in what will be committed)
website/
nothing added to commit but untracked files present (use "git add" to track)
我還能做些什么來將我的網站設定為 Github?
uj5u.com熱心網友回復:
如果您的計算機上已經有本地 git 存盤庫,則需要將遠程設定為遠程 git 存盤庫,例如:
git remote add origin <link here>
然后您需要暫存更改:
git add .
git commit -m "Initial commit"
git push
uj5u.com熱心網友回復:
"重新初始化 /Users/username/test/website/.git/ 中的現有 Git 存盤庫",
看起來您的計算機上已經有一個本地 git 存盤庫。下一步是在 github 中創建存盤庫,獲取 https 鏈接并執行
git remote add origin <your repository https url>
git add .
git commit -m "intializing project"
git push origin <your branch name, ex. master>
uj5u.com熱心網友回復:
- 首先登錄 GitHub 并創建一個與您要在 Github 中推送的內容同名的存盤庫。存盤庫名稱 = 專案名稱。
- 然后進入你的專案的終端,cd(你的專案名),一一運行下面的命令。【好像你不在你的專案的根目錄】

echo "# (your project name)" >> README.md
git init
git add README.md
git commit -m "first commit"
... ...
git remote add origin https://github.com/Here will be your github acc. name/(Your Repository name = Project name). git
git push -u origin main
- 如果您從另一個 repo 克隆,則
remote add originremote set-url不要像 https .. 那樣休息。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/515228.html
標籤:混帐github
