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. Android --Search界面样式

    Lay_Weight 权重属性的使用 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android ...

  2. ON_NOTIFY_REFLECT : Message Reflection for Windows Controls

    转自: https://msdn.microsoft.com/en-us/library/eeah46xd.aspx TN062: Message Reflection for Windows Con ...

  3. WCF笔记

    http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iparameterinspector.aftercall ...

  4. urllib下载文件

    import urllib 1.用urlib.urlretrieve f = urllib.urlretrieve('http://www.baidu.com/img/bdlogo.gif','/tm ...

  5. js - ajax中的get和post说明

    转自:http://www.cnblogs.com/hateyoucode/archive/2009/12/09/1620050.html 一.谈Ajax的Get和Post的区别 Get方式:   用 ...

  6. G面经prepare: Android Phone Unlock Pattern

    1 2 3 4 5 6 7 8 9 只有中间没有其他键的两个键才能相连,比如1可以连 2 4 5 6 8 但不能连 3 7 9 但是如果中间键被使用了,那就可以连,比如5已经被使用了,那1就可以连9 ...

  7. Lintcode: Search Range in Binary Search Tree

    Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all t ...

  8. 【皇甫】☀亲爱的~help me

     亲爱的,我不知道该怎么把我想对你说的话表达出来,希望我对你的认识真的像下面的内容一样,如果我有错,那说明我还不够了解你... 希望我们能够一起走到最后吧... 首先,说说最近的吧,  在我还没有和你 ...

  9. BZOJ 4052: [Cerc2013]Magical GCD

    以一个数字开头的子序列的gcd种类不会超过logn种,因此去找相同gcd最长的位置,更新一下答案,复杂度O(nlogn^2) #include<cstdio> #include<al ...

  10. js 获取select 中option 的个数

    //document.writeln(document.getElementById("sel").options.length); //document.writeln(docu ...