git 上传本地文件到github

1 git config --global user.name "Your Real Name"
2 git config --global user.email you@email.address
git init
git add .
git commit -m 'Test'
git remote add origin git@github.com:XXX/XXX.git 3 git push -u origin master
一些可能遇到的问题解决:
如果输入$ git remote add origin git@github.com:djqiang(github帐号名)/gitdemo(项目名).git
提示出错信息:fatal: remote origin already exists.
解决办法如下:
1、先输入$ git remote rm origin
2、再输入$ git remote add origin git@github.com:djqiang/gitdemo.git 就不会报错了!
3、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section ‘remote.origin’. 我们需要修改gitconfig文件的内容
4、找到你的github的安装路径,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc
5、找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!
如果输入$ ssh -T git@github.com
出现错误提示:Permission denied (publickey).因为新生成的key不能加入ssh就会导致连接不上github。
解决办法如下:
1、先输入$ ssh-agent,再输入$ ssh-add ~/.ssh/id_key,这样就可以了。
2、如果还是不行的话,输入ssh-add ~/.ssh/id_key 命令后出现报错Could not open a connection to your authentication agent.解决方法是key用Git Gui的ssh工具生成,这样生成的时候key就直接保存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令行来做。
3、最好检查一下在你复制id_rsa.pub文件的内容时有没有产生多余的空格或空行,有些编辑器会帮你添加这些的。
如果输入$ git push origin master
提示出错信息:error:failed to push som refs to …….
解决办法如下:
1、先输入$ git pull origin master //先把远程服务器github上面的文件拉下来
2、再输入$ git push origin master
3、如果出现报错 fatal: Couldn’t find remote ref master或者fatal: ‘origin’ does not appear to be a git repository以及fatal: Could not read from remote repository.
4、则需要重新输入$ git remote add origingit@github.com:djqiang/gitdemo.git
使用git在本地创建一个项目的过程
$ makdir ~/hello-world //创建一个项目hello-world
$ cd ~/hello-world //打开这个项目
$ git init //初始化
$ touch README
$ git add README //更新README文件
$ git commit -m ‘first commit’ //提交更新,并注释信息“first commit”
$ git remote add origin git@github.com:defnngj/hello-world.git //连接远程github项目
$ git push -u origin master //将本地项目更新到github项目上去

Create a new repository on the command line

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:teamtogether/TestProject.git
git push -u origin master

Push an existing repository from the command line

git remote add origin git@github.com:teamtogether/TestProject.git
git push -u origin master

git 上传本地文件到github的更多相关文章

  1. 用git上传本地文件到github

    1.在自己的github账号下新建仓库--------得到github仓库地址 2.本地安装git---在将要克隆的文件夹下 右击点击Git Bash Here 3.输入命令 $ git clone ...

  2. 两种方法上传本地文件到github

    https://www.jianshu.com/p/c70ca3a02087 自从使用github以来,一直都是在github网站在线上传文件到仓库中,但是有时因为网络或者电脑的原因上传失败.最重要的 ...

  3. 两种方法上传本地文件到github(转)

    自从使用github以来,一直都是在github网站在线上传文件到仓库中,但是有时因为网络或者电脑的原因上传失败.最重要的原因是我习惯本地编辑,完成以后再一起上传github.看过了几个教程,总结出最 ...

  4. Git安装及密钥的生成并上传本地文件到GitHub上

    之前用的GitHub,不太熟练,一直在上传的过程中遇到了一些问题,看了网上诸多教程,总觉得很乱,特参考一些资料,总结了一篇完整的操作步骤,从下载安装到上传文件,亲测有效 1.下载Git软件:https ...

  5. 上传本地文件到GitHub上

    问题解决 今天在windows上上传本地文件到github,出现用户名和仓库不匹配的情况,解决方式如下: 打开控制面板,选择用户账户 把该删除的账户删除一下就行了. 上传文件的步骤如下: 将上传的文件 ...

  6. 第一次使用Git上传本地项目到github上

    对于程序原来说都听说过GitHub,GitHub有许多开源的的项目和一些前沿的技术.因为自己在刚刚开始使用Git把自己写的一些小dome放到GitHub上遇到许多的坑,这么长时间过去了,想对第一次使用 ...

  7. 用git上传本地项目到github上

    首先确认自己已经安装了git,打开git bash,输入ssh-keygen -t rsa -C "自己的邮箱地址@XXX.com" ,生成自己的公钥与私钥   一路默认回车,会生 ...

  8. 上传本地文件到github仓库基本操作

    上传文件到github时老师忘记指令,或者总是出一些错,每次都要百度浪费时间,因此将常用操作指令归纳卸载这里,以后再也不要担心百度找帖子了... 第一步:新建仓库 新建仓库步骤省略,最后我们得到一个仓 ...

  9. 上传本地文件到github(码云)上(小乌龟方式,sourcetree方式)

    一:上传文件到 github 1.打开 https://github.com/ 登录github账号(没有的自己创建),点击右上角创建新仓库 在打开的页面中填写  名字 点击 Create repos ...

随机推荐

  1. Python模块 (psutil)

    psutil psutil是Python中一个系统信息检索模块,可以获取(系统.CPU.内存.网络.磁盘)等信息,可以应用于系统的监控.健康状态检查,等同于shell中的ps.free.top.df功 ...

  2. 【转】用CSS代码写出的各种形状图形的方法

    一共收集整理了图形20个,比较实用,同时也为了熟悉CSS的代码.整合了一下,有错误欢迎指出. 1.正方形 #square {width: 100px;height: 100px;background: ...

  3. 一次数据库hang住的分析过程

    现象: 普通用户和sysdba都无法登陆,业务中断 分析过程: 1.先做hanganalyze和systemstate dump $sqlplus -prelim "/as sysdba&q ...

  4. 使用dbms_system追踪其它session

    dbms_system是内部包,建议在官方指导下使用该包. SQL> desc dbms_system PROCEDURE ADD_PARAMETER_VALUE Argument Name T ...

  5. nodejs发起HTTPS请求并获取数据

    摘要:在网站中有时候需要跨域请求数据,直接用Ajax无法实现跨域,采用其他方式需要根据不同的浏览器做相应的处理.用Nodejs可以很好的解决这些问题,后台引用HTTPS模块,发送和返回的数据均为JSO ...

  6. PostgreSQL auto_explain

    The auto_explain module provides a means for logging execution plans of slow statements automaticall ...

  7. PHP和JS实现多按钮提交表单

    JS: <html> <head> <script> function submitit1() //交由程序1处理 { document.myForm.action ...

  8. 2-sat(and,or,xor)poj3678

    Katu Puzzle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7949   Accepted: 2914 Descr ...

  9. [转]Eclipse Java注释模板设置详解

    原文链接:http://blog.csdn.net/ahhsxy/archive/2009/09/11/4542682.aspx 设置注释模板的入口: Window->Preference-&g ...

  10. Eclipse安装Ruby插件应该注意的几点

    http://www.aptana.com/products/studio3/success_plugin.html Installing via Eclipse Please copy the fo ...