(備忘用,不一定正确)
* 送出代碼
cd xxx (切換到工作目錄)
git add . (注意後面的是一個點)
git commit -m 'adding xxx' (後面是日志内容)
git push origin master (送出到origin節點的master分支,官方的做法是git push -r origin master)
* Windows指令行建立ssh key(用于git clone [email protected]:xxx/xxx.git和送出私人倉庫代碼)
參考:
https://help.github.com/
https://help.github.com/articles/generating-ssh-keys/
https://help.github.com/articles/keeping-your-ssh-keys-and-application-access-tokens-safe/
https://help.github.com/articles/caching-your-github-password-in-git/
http://www.cnblogs.com/sheldonxu/archive/2012/09/17/2688281.html
環境:
Windows XP
Git-1.9.2-preview20140411(msysgit最新版http://msysgit.github.io/)
$ git config --global user.name <github注冊使用者名>
$ git config --global user.email <github注冊郵箱名>
$ ls -al ~/.ssh
$ ssh-keygen -t rsa -C <github注冊郵箱名>
(提示save the key時,直接回車(使用預設路徑儲存鑰匙),然後輸入github注冊密碼(沒有回響顯示,會提示輸入兩次))
$ ssh-agent -s(官方建議,不過有問題)
$ ssh-add ~/.ssh/id_rsa(失敗,改用ssh-agent bash)
$ ssh-agent bash
bash-3.1$ ssh-add ~/.ssh/id_rsa(成功)
(到了這裡需要手工把C:\Documents and Settings\Administrator\.ssh的id_rsa.pub檔案内容粘貼到github網站->設定->SSH Keys (https://github.com/settings/ssh,點選Add SSH Key按鈕),标題可以任意指定
$ ssh -T [email protected](測試,隻要顯示authenticated就表示成功,不要理會shell access警告)
Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.
$ git clone [email protected]:xxx/xxx.git(在網頁上建立github代碼庫,然後使用右下角的SSH clone URL克隆代碼)
(以下引用http://www.cnblogs.com/sheldonxu/archive/2012/09/17/2688281.html)
執行ssh-add時出現Could not open a connection to your authentication agent
若執行ssh-add /path/to/xxx.pem是出現這個錯誤:Could not open a connection to your authentication agent,則先執行如下指令即可:
ssh-agent bash
更多關于ssh-agent的細節,可以用 man ssh-agent 來檢視
(TODO:待補充)