如何用git创建一个项目

                                     如何用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"

 

测试结果

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值