一直是在windows下使用github,windows崩了后就不得不在ubuntu下使用
首先注册到github上注册个帐号,记住自己的用户名、邮箱及密码。
1、在ubuntu下安装git
sudo apt-get install git git-core git-doc
2、配置本机的git
$ git config --global user.name "abcd" $ git config --global user.email abcd@efgh.com这里的abcd是你在github上的用户名,abcd@efgh.com是你的注册邮箱
3、生成你ssh的密钥
$ ssh-keygen -t rsa -C "abcd@efgh.com" //邮箱同上使用默认的路径即可
4、将生成的密钥提交给github
vim /home/××××/.ssh/id_rsa.pub
复制里面的密钥
到你的github上去,在账户设置里填入密钥(title可以随便写)
5、检验是否已经连上了github
$ ssh git@github.com //正常情况下,回显如下 PTY allocation request failed on channel 0 Hi XXXX! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
6、首次推送
$ cd tmp //进入你想推送目录 $ git init //设置该目录为推送 $ touch README //生成readme $ git add README //加入修改列表 $ git commit -m 'first commit' //递交修改声明 $ git remote add origin git@github.com:abcd/tmp.git //为远程Git更名为origin,origin你也可以写成其他的名字
//
一般在push前 ,先pull原库中的文件,使得本地和服务器端的文件保持一致,即
$ git pull origin master
//第一次使用时,添加远程代码库到配置中去,如果你有多个代码库,可以命名2为origin2等等 $ git push -u origin master //推送此次修改至origin仓库的master分支
//
7、相关命令
$ git status //查看状态 $ git init //设置该目录为
$ git remote //查看远程仓库$ git log //显示log
To be continued
http://blog.youkuaiyun.com/tangbin330/article/details/9128765
http://www.ubuntumanual.org/posts/393/how-to-setup-and-use-github-in-ubuntu
http://rogerdudler.github.io/git-guide/index.zh.html
http://www.zhihu.com/question/20070065http://www.cnblogs.com/cspku/articles/Git_cmds.html