git提交代码(一)

1、在http://git.oschina.net/注册用户,下载git:https://git-scm.com/download/

2、添加ssh免登录通道,个人信息模块有说明

      ssh-keygen -t rsa -C "[email protected]"# Creates a new ssh key using the provided email

      把公钥添加到ssh-key中

     测试 ssh -T [email protected] 成功回应 Welcome to Git@OSC, yourname!

3、创建项目 xxxx

4、上传本地代码到xxxx git仓库中

touch README.md //新建说明文件 如有就不需在创建
git init //在当前项目目录中生成本地git管理,并建立一个隐藏.git目录
git add . //添加当前目录中的所有文件到索引
git commit -m "first commit" //提交到本地源码库,并附加提交注释
git remote add origin 粘贴复制的地址 //添加到远程项目,别名为origin
git push -u origin master //把本地源码库push到github 别名为origin的远程项目中,确认提交

5、遇到问题

error: failed to push some refs to '[email protected]:xxxx.git'

6、解决方法

git pull

可以通过如下命令进行代码合并【注:pull=fetch+merge]   git pull --rebase origin master

在提交git push -u origin master,成功

下次继续。。。。

猜你喜欢

转载自491569462-qq-com.iteye.com/blog/2337717