文章目錄
本地創建好項目之後,項目是在本地,此時,需要將本地的代碼庫提交至遠端,下面是總結的一系列操作
1、創建完項目結構,沒有分支
git add . --將創建的項目結構,添加至本地倉庫
git commit -m “first-commit” 提交項目至本地倉庫,此時就會創建出本地分支,master
2、在github上新建遠程倉庫
此時,遠程倉庫就創建完畢了
紅色框中的第一個是遠程倉庫的地址,可以使用SSH 或 HTTP的方式提交
第二個是本地倉庫提交至遠程倉庫的命令
3、按照上圖中紅色框中的命令,就可以提交本地
倉庫至遠端了
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:crzaywh/exercise-design-mode.git
git push -u origin master
4、提交過程中可能會遇到全局配置文件config 中沒有配置用戶和郵箱地址的情況
git config -l
查看當前項目的本地config的配置,查看有沒有不對的地方,進行更改
5、git pull,push每次都需要輸入密碼的問題解決
使用Git pull,push代碼每次都需要輸入密碼的原因是在添加遠程庫的時候使用了https的方式。。所以每次都要用https的方式push到遠程庫;
1、查看下當前使用的傳輸協議:
git remote -v
origin https://github.com/tigerwow/exercise.git (fetch)
origin https://github.com/tigerwow/exercise.git (push)
2、重新設置成ssh的方式:
git remote rm origin
git remote add origin git@github.com:username/repository.git
git push -u origin 當前分支名
git remote -v
origin git@github.com:tigerwow/exercise.git (fetch)
origin git@github.com:tigerwow/exercise.git (push)