GitHub 操作流程示例
最新文章:Virson's Blog
參考文章: 博客園-Web前端開發,博客園-喻頭快跑,GotGitHub
首先。通過github網站新建一個倉庫,得到倉庫地址
https://github.com/mawanglin2008/test.git
接著回到客戶端,打開git shell:
//在客戶端配置賬戶信息 git config --global user.name 'mawanglin2008' //設置初始賬號id git config --global user.email 'test@test.com' //設置郵箱 //在本地建立自己的版本倉庫 cd d: //我把版本倉庫建立在D盤,切換到D盤目錄 mkdir a //新建文件夾,注意本地倉庫名要和git上建立的倉庫名一致 cd a //進入a目錄 git init //初始化版本倉庫 touch README //建立一個README文件,之后編輯README git add README //將文件添加到上傳隊列 git commit -m 'information' //提交 git remote add origin https://github.com/mawanglin2008/test.git //遠程地址 //如果這里有錯,錯誤信息為fatal: remote origin already exists時,請輸入:git remote rm origin,然后繼續輸入上面那行繼續走流程。 git push origin master //上傳到遠程版本庫。輸入github郵箱和密碼
ok,已經完成github線上建立倉庫和線下倉庫關聯。
新建遠程分支,分賬號先登錄git config設置完畢,去github頁面上找到源目錄,fork先。
git clone https://github.com/mawanglin2008/test.git //克隆,并在本地目錄自動建立本地倉庫 cd a git checkout -b dev //建立并切換到dev分支 git push --set-upstream origin dev //向主分支提交新建分支信息 //輸入主分支郵箱和密碼,通過。遠程分支建立完畢 //編輯內容 git add . git commit -m 'add dev' //匯總目錄 git push //提交
遠程分支工作完畢,回到master工作環境:
git checkout master git merge dev --no-ff //merge合并工作先 git pull origin dev //從dev分支拉回較新代碼 git push //更新至master賬號下面,共其他分支pull
當出現以下錯誤時:
Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
解決辦法:
ls -al ~/.ssh //check for SSH keys ssh-keygen -t rsa -C "test@test.com" //generate a new SSH keys //enter后,輸入兩次passphrase,之后生成了SSH key pbcopy < ~/.ssh/id_rsa.pub //拷貝公有秘鑰,到github上"add SSH key" ssh -T git@github.com //輸入passphrase后連接成功!
其他參考手冊:
《Git Community Book 中文版》:http://gitbook.liuhui998.com/
《GIT GUI使用》:http://hi.baidu.com/lettoo/blog/item/e2e7f30fec72bdf6ab645789.html
《Generating SSH keysGenerating SSH keys》:https://help.github.com/articles/generating-ssh-keys/

浙公網安備 33010602011771號