(备忘用,不一定正确)
* 提交代码
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 git@github.com: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 bashbash-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 git@github.com(测试,只要显示authenticated就表示成功,不要理会shell access警告)Hi username! You've successfully authenticated, but GitHub does not# provide shell access.$ git clone git@github.com: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:待补充)