如何用git创建一个项目
查看我的代码:https://github.com/aleafboat/study.git
微信:wang_cyi
第一步:Ubuntu 10.10 安装git
sudo apt-get install git git-core
第二步:创建一个本地创建的仓库
cd /home/wang/study/code
git init
第三步:在仓库中下载代码
git clone git://github.com/aleafboat/study.git
此时 基本的快照 建立
第三步:git add 添加文件到缓存
git add 1.cpp client.cpp
git status -s
第四步:git commit 记录缓存内容的快照
git commit -m "new file" -a
第五部 :分享与更新项目 别人可以下载你的代码
1
git remote add github git@github.com:aleafboat/study.git
作用: 为你的项目添加一个新的远端仓库 github 用来存放远程代码
2 git remote -v
//git remote 列出远端别名
3 git push 推送你的新分支与数据到某个远端仓库
【关键】Add your SSH key to GitHub
a :ssh-keygen -C 'your@email.address' -t rsa //创建一个ssh key
ssh-keygen -t rsa -C "wang_cyi@163.com"
b :在 https://github.com/settings/ssh 设置自己的ssh kyey
wang@ubuntu:~/.ssh$ ssh-keygen -t rsa -C "wang_cyi@163.com"
c 测试结果
ssh -T git@github.com
wang@ubuntu:~/.ssh$ ssh -T git@github.com
Hi aleafboat! You've successfully authenticated, but GitHub does not provide shell access.
参考文档:
1 https://help.github.com/articles/generating-ssh-keys#platform-linux
2 http://architecture1.riaos.com/?p=3059916
3 http://feuyeux.iteye.com/blog/1324684
第六部 提交远程代码:
1 查看分支代码和远程
wang@ubuntu:~/study/code$ git branch
* master
testing
wang@ubuntu:~/study/code$ git remote
github
2 push分支代码到远程
git push github master
【出现错误】
1 How to merge remote changes at GitHub?
解决方式:
Switch to branch "foo" and update it:
$ git checkout foo
$ git pull
=
作用: git-push - Update remote refs along with associated objects