提交代码到GitHub(常见错误)
2013-03-13 16:05
295 查看
引用
1.创建一个新的repository:
先在github上创建并写好相关名字,描述。
$cd ~/hello-world //到hello-world目录
$git init //初始化
$git add . //把所有文件加入到索引(不想把所有文件加入,可以用gitignore或add 具体文件)
$git commit //提交到本地仓库,然后会填写更新日志( -m “更新日志”也可)
$git remote add origin git@github.com:WadeLeng/hello-world.git //增加到remote
$git push origin master //push到github上
2.更新项目(新加了文件):
$cd ~/hello-world
$git add . //这样可以自动判断新加了哪些文件,或者手动加入文件名字
$git commit //提交到本地仓库
$git push origin master //不是新创建的,不用再add 到remote上了
3.更新项目(没新加文件,只有删除或者修改文件):
$cd ~/hello-world
$git commit -a //记录删除或修改了哪些文件
$git push origin master //提交到github
4.忽略一些文件,比如*.o等:
$cd ~/hello-world
$vim .gitignore //把文件类型加入到.gitignore中,保存
然后就可以git add . 能自动过滤这种文件
5.clone代码到本地:
$git clone git@github.com:WadeLeng/hello-world.git
假如本地已经存在了代码,而仓库里有更新,把更改的合并到本地的项目:
$git fetch origin //获取远程更新
$git merge origin/master //把更新的内容合并到本地分支
6.撤销
$git reset
7.删除
$git rm * // 不是用rm
//------------------------------常见错误-----------------------------------
1.$ git remote add origin git@github.com:WadeLeng/hello-world.git
错误提示:fatal: remote origin already exists.
解决办法:$ git remote rm origin
然后在执行:$ git remote add origin git@github.com:WadeLeng/hello-world.git 就不会报错误了
2. $ git push origin master
错误提示:error:failed to push som refs to
解决办法:$ git pull origin master //先把远程服务器github上面的文件拉先来,再push 上去。
本人遇到的还有一个错误就是,工程传进github 了可是里头缺少文件,
解决方法 $git add . (注意一点 。 )表示添加所有文件,
如果出现无法提交的情况
如:
引用
error: failed to push some refs to ...
试试以下方法来强制提交。
http://www.cnblogs.com/tjuyyl/archive/2011/08/21/2147695.html
Java代码
![](http://musicbox95351.iteye.com/images/icon_star.png)
git push https://github.com/account/repositeName.git +master
1.创建一个新的repository:
先在github上创建并写好相关名字,描述。
$cd ~/hello-world //到hello-world目录
$git init //初始化
$git add . //把所有文件加入到索引(不想把所有文件加入,可以用gitignore或add 具体文件)
$git commit //提交到本地仓库,然后会填写更新日志( -m “更新日志”也可)
$git remote add origin git@github.com:WadeLeng/hello-world.git //增加到remote
$git push origin master //push到github上
2.更新项目(新加了文件):
$cd ~/hello-world
$git add . //这样可以自动判断新加了哪些文件,或者手动加入文件名字
$git commit //提交到本地仓库
$git push origin master //不是新创建的,不用再add 到remote上了
3.更新项目(没新加文件,只有删除或者修改文件):
$cd ~/hello-world
$git commit -a //记录删除或修改了哪些文件
$git push origin master //提交到github
4.忽略一些文件,比如*.o等:
$cd ~/hello-world
$vim .gitignore //把文件类型加入到.gitignore中,保存
然后就可以git add . 能自动过滤这种文件
5.clone代码到本地:
$git clone git@github.com:WadeLeng/hello-world.git
假如本地已经存在了代码,而仓库里有更新,把更改的合并到本地的项目:
$git fetch origin //获取远程更新
$git merge origin/master //把更新的内容合并到本地分支
6.撤销
$git reset
7.删除
$git rm * // 不是用rm
//------------------------------常见错误-----------------------------------
1.$ git remote add origin git@github.com:WadeLeng/hello-world.git
错误提示:fatal: remote origin already exists.
解决办法:$ git remote rm origin
然后在执行:$ git remote add origin git@github.com:WadeLeng/hello-world.git 就不会报错误了
2. $ git push origin master
错误提示:error:failed to push som refs to
解决办法:$ git pull origin master //先把远程服务器github上面的文件拉先来,再push 上去。
本人遇到的还有一个错误就是,工程传进github 了可是里头缺少文件,
解决方法 $git add . (注意一点 。 )表示添加所有文件,
如果出现无法提交的情况
如:
引用
error: failed to push some refs to ...
试试以下方法来强制提交。
http://www.cnblogs.com/tjuyyl/archive/2011/08/21/2147695.html
Java代码
![](http://musicbox95351.iteye.com/images/icon_star.png)
git push https://github.com/account/repositeName.git +master
相关文章推荐
- Github 提交代码出现错误提示
- 使用Git往github上提交代码时出现[packet_write_wait connection to xx.xx.xx.xx Broken pipe]错误的解决办法:
- 提交代码到GitHub SSH错误解决方案
- github 提交 常见操作和常见错误
- git发布代码到github过程和常见错误
- 使用git往github上提交代码时出现[packet_write_wait connection to xx.xx.xx.xx Broken pipe]错误的解决办法
- git发布代码到github过程和常见错误
- 本地代码上传gitHub 常见错误
- github常见操作和常见错误!
- github https方式免密码提交代码 在git config 中添加用户名密码
- GitHub使用教程及常见错误解决
- Socket常见错误代码与描述
- http协议的状态码——400,401,403,404,500,502,503,301,302等常见网页错误代码
- java代码审查常见错误整理
- 本地代码提交至gitHub远程仓库的方法
- ios arc (四)将mrc代码转成arc 常见错误
- 【代码管理】GitHub超详细图文攻略 - Git客户端下载安装 GitHub提交修改源码工作流程 Git分支 标签 过滤 Git版本工作流
- github 提交报403 forbidden的错误解决
- windows上第一次提交本地代码到github