git提交本地项目到github
2015-12-25 17:28
393 查看
git学习笔记(windows平台)
安装git 在需要将项目提交到git的根目录下打开git bush 1 git init 初始化一个git仓库 //将本地文件添加master,先add一个文件 2 git add 一个文件 或者 git add . 提交当前目录中所有的文件 3 git commit -m "" //链接远程仓库 4 git remote add "远程仓库的地址别名默认是origin" git@git.oschina.net:fuxiaohui/git项目名 在需要将项目提交到git的根目录下打开git bush 5 git remote -v 如果出现以下错误 一,To https://git.oschina.net/fuxiaohui/itone-core.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://git.oschina.net/fuxiaohui/itone-core.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://git.oschina.net/fuxiaohui/itone-core.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. 查看本地分支命令 git branch 查看远程分支命令 git branch -a 执行 git branch --set-upstream-to=origin/远程分支的名字 本地分支的名字 二,如果push出现错误说明本地仓库与远程仓库不一致,得吧远程仓库的值fetch到本地来 7 git fetch 8 git merge 9 $ git fetch 10 $ git merge 这2句命令等价于 $ git pull 可是,这时候又出现了如下的问题: 1上面出现的 [branch "master"]是需要明确(.git/config)如下的内容 [branch "master"] remote = origin merge = refs/heads/master 这等于告诉git2件事: 1,当你处于master branch, 默认的remote就是origin。 2,当你在master branch上使用git pull时,没有指定remote和branch,那么git就会采用默认的remote(也就是 origin)来merge在master branch上所有的改变 如果不想或者不会编辑config文件的话,可以在bush上输入如下命令行: $ git config branch.master.remote origin $ git config branch.master.merge refs/heads/master 之后再重新git pull下。最后git push你的代码吧。
6 git push -u "远程仓库地址别名" master
判断公钥是否添加成功 ssh -T git@git.oschina.net
相关文章推荐
- spring mvc注解
- 等比数列求和(C++实现)
- vs2013新建asp.net web 项目报错,此模板尝试加载组件程序集nuget
- Java并发编程类学习总结
- Spring MVC 4 学习1:环境的配置
- asp.net mvc中构建htmlHelper的checkboxlist
- Java并发编程类学习五(同步工具)
- MyEclipse中Ctrl+Alt+向下方向键变成旋转屏幕解决方法
- C#.NET 大型企业信息化系统集成快速开发平台 4.2 版本 - 外部服务调用、内部服务调用优化,面向服务化的
- php【基础学习八】URL编解码
- Java并发编程类学习四(线程安全的类)
- Java并发编程类学习三(线程的执行)
- Java并发编程类学习二(线程的包装)
- hadoop 使用HA后java api连接获取 FileSystem
- Java线程(五):Timer和TimerTask
- &#x开头的是什么编码呢。浏览器可以解释它。如中国等同与中文"中国"?
- 巧妙的运用宏和函数写好你的C代码
- Java并发编程类学习一(线程的定义)
- java程序优化总结
- javaweb中Filter(过滤器)的常见应用