github建立repo,本地匯入git專案到github

世有因果知因求果發表於2015-05-18

  一般地,在註冊好github賬號之後,你需要做的事情就是在github上建立一個repo,該repo將成為你的origin(central)repo,隨後你就可以將本地的專案git repo匯入到這個github repo中。這樣做的好處就是github免費成為了一個供你或你的團隊工作學習的一個公共庫。

在這裡簡單列出這個過程中所使用到的git命令:

git config --global color.status auto第一次本地使用git的話,可能要用到它,這樣就可以以彩色的方式展示你的git命令輸出了;

git config --global user.email "your-email-id@example.com"
git config --global user.name "Your-Github-UserName"

上述命令將配置將來github中需要的認證授權及版權資訊。

git remote add origin https://github.com/xxx/gittest.git 

git remote set-url origin https://Your-Github-UserNAme@github.com/Your-Github-UserNAme/REPO-NAME 
上面兩條比較關鍵,否則可能出現403 forbidden錯誤

git remote -v                                               
origin  https://xxx@github.com/xxx/gittest.git (fetch)                                  
origin  https://xxx@github.com/xxx/gittest.git (push) 
git push -u origin master
 

 

相關文章