好长时间没上来弄东西了,今天回来先开始弄下Git,之后再继续写uboot与kernel的编译,在版本控制下更加宏观地观察每次的变化。

  1、在ubuntu中安装git

$ sudo apt-get install git git-core

  2、配置本机的git

$ git config --global user.name "abcd"
$ git config --global user.email abcd@efgh.com

  3、生成密钥

$ ssh-keygen -t rsa -C "abcd@efgh.com" //邮箱同上

  4、提交密钥

vim /home/linx/.ssh/id_rsa.pub //复制里面的密钥

  到github网页中登陆自己的账号,然后再account setting中,找到SSH KEY讲复制的密钥加入(需要再次输入github的密码)

  5、检验是否链接上了github

$ ssh git@github.com
//正常情况下,回显如下
PTY allocation request failed on channel 0
Hi plinx! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

  6、首次推送

$ mkdir tmp      //创建推送目录
$ cd tmp //进入推送目录
$ git init //设置该目录为推送
$ touch README //生成readme
$ git add README //加入修改列表
$ git commit -m 'first commit' //递交修改声明
$ git remote add origin git@github.com:abcd/tmp.git //为远程Git更名为origin
$ git push -u origin master //推送此次修改

  然后各种问题从这里开始了,以下谈一下解决的方法:

  问题一:

ERROR: Repository not found.

  这个问题是因为在你推送的github账户中,并没有这个Repository。

  解决方法:

  1)检查自己的github中的Repository,检查自己创建的目录,必须要两者一致;

  2)先git clone下github中的Repository,然后再进行更改,这样就一定一致了。

  问题二:

Agent admitted failure to sign using the key.
Permission denied (publickey)

  这个问题是因为你的ssh key并没有加入到你想git的github账户的ssh key中,所以没有访问权限。

  解决方法:

  1)重新拷贝一份当前的~/.ssh/id_rsa.pub中的ssh key到github中添加;

  2)先删除~/.ssh/in_rsa*文件,然后重新ssh-keygen一份sshkey来生成密钥,然后复制到github,接着ssh链接github来检验是否成功联通。

  问题三:

//出现如下提示
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ...

  这个问题是因为,github中已经有了这个代码,不允许你覆盖它。

  解决方法:

  1)强制推送,一般不推荐!

$ git push -f

  2)

$ git pull

  然后将出现其他提示,具体意思是说branch与merge未指定,git无法选择要推送的分支。

  可以通过修改 .git/config文件中的下列内容

[branch "master"]
remote = origin
merge = refs/heads/master

  也可以直接命令行修改

$ git config branch.master.remote origin
$ git config branch.master.merge ref/heads/master

  目前了解到的也就这三个问题了。

  之后就可以成功得推送了。

转载:http://www.cnblogs.com/plinx/archive/2013/04/08/3009159.html

[root@localhost Jessica]# mkdir tmp
[root@localhost Jessica]# cd tmp
[root@localhost tmp]# git init
Initialized empty Git repository in /root/Jessica/Jessica/tmp/.git/
[root@localhost tmp]# touch README
[root@localhost tmp]# git add README
[root@localhost tmp]# vim README
[root@localhost tmp]# vim myfile.txt
[root@localhost tmp]# git add .
[root@localhost tmp]# git commit -m 'first commit'
[master (root-commit) 4fc0345] first commit
files changed, insertions(+), deletions(-)
create mode README
create mode myfile.txt
[root@localhost tmp]# git remote add origin git@github.com:Jessicahust/tmp.git
[root@localhost tmp]# git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
[root@localhost tmp]# git push -u origin master
To git@github.com:Jessicahust/tmp.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Jessicahust/tmp.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
[root@localhost tmp]# git push -f
Counting objects: , done.
Delta compression using up to threads.
Compressing objects: % (/), done.
Writing objects: % (/), bytes, done.
Total (delta ), reused (delta )
To git@github.com:Jessicahust/tmp.git
+ ae65e0f...4fc0345 master -> master (forced update)
[root@localhost tmp]# git clone https://github.com/Jessicahust/tmp.git
Initialized empty Git repository in /root/Jessica/Jessica/tmp/tmp/.git/
remote: Counting objects: , done.
remote: Compressing objects: % (/), done.
remote: Total (delta ), reused (delta )
Unpacking objects: % (/), done.
[root@localhost tmp]# cd tmp/
[root@localhost tmp]# ll
总用量
-rw-r--r--. root root 12月 : myfile.txt
-rw-r--r--. root root 12月 : README
[root@localhost tmp]# vim myfile.txt
[root@localhost tmp]# git push -u origin master
error: The requested URL returned error: Forbidden while accessing https://github.com/Jessicahust/tmp.git/info/refs fatal: HTTP request failed
[root@localhost tmp]# git remote rm origin
[root@localhost tmp]# git push -u origin master
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
[root@localhost tmp]# git push -u origin master
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
[root@localhost tmp]# git commit -m 'second commit'
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: myfile.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
[root@localhost tmp]# git remote add origin git@github.com:Jessicahust/tmp.git
[root@localhost tmp]# git push -u origin master
Branch master set up to track remote branch master from origin.
Everything up-to-date
[root@localhost tmp]# vim myfile.txt
[root@localhost tmp]# git add .
[root@localhost tmp]# git commit -m 'second commit'
[master 68d8831] second commit
files changed, insertions(+), deletions(-)
[root@localhost tmp]# git push -u origin master
Counting objects: , done.
Delta compression using up to threads.
Compressing objects: % (/), done.
Writing objects: % (/), bytes, done.
Total (delta ), reused (delta )
To git@github.com:Jessicahust/tmp.git
4fc0345..68d8831 master -> master
Branch master set up to track remote branch master from origin.

将自己的githubpull下来修改了传送

[root@localhost vimide]# git clone https://github.com/Jessicahust/vimide.git
Initialized empty Git repository in /root/vimide/vimide/vimide/.git/
remote: Counting objects: , done.
remote: Compressing objects: % (/), done.
remote: Total (delta ), reused (delta ), pack-reused
Unpacking objects: % (/), done.
[root@localhost vimide]# git add bundle
[root@localhost vimide]# git commit -m 'first commit'
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# vimide/
nothing added to commit but untracked files present (use "git add" to track)
[root@localhost vimide]# git init
Reinitialized existing Git repository in /root/vimide/vimide/.git/
[root@localhost vimide]# git add README
[root@localhost vimide]# git add bundle
[root@localhost vimide]# git add .\
> ^C
[root@localhost vimide]# git add .
[root@localhost vimide]# git commit -m 'second commit'
[master 427c834] second commit
files changed, insertions(+), deletions(-)
create mode vimide
[root@localhost vimide]# git remote add origin git@github.com:Jessicahust/vimide.git
fatal: remote origin already exists.
[root@localhost vimide]# git remote rm origin
[root@localhost vimide]# git remote add origin git@github.com:Jessicahust/vimide.git
[root@localhost vimide]# git push -u origin master
Counting objects: , done.
Delta compression using up to threads.
Compressing objects: % (/), done.
Writing objects: % (/), bytes, done.
Total (delta ), reused (delta )
To git@github.com:Jessicahust/vimide.git
70d526e..427c834 master -> master
Branch master set up to track remote branch master from origin.

Git链接到自己的Github(1)简单的开始的更多相关文章

  1. SVN和git的使用(附github的简单玩法)

    今天简单的总结了下SVN和git的使用,也尝试了下github,应该好好提高下自己的英文水平了,梦想有一天不再使用任何翻译软件. [svn]:集中式的代码管理工具(版本控制工具--版本记录) 1> ...

  2. Git链接到自己的Github(2)进阶使用

    接着上一篇的,从github clone下代码. 1.先查看当前开发分支 $ cat .git/HEAD ref: refs/heads/master 这里的master是默认分支. 2.查看当前状态 ...

  3. git链接到远程github上

    Git链接到自己的Github(1)简单的开始 好长时间没上来弄东西了,今天回来先开始弄下Git,之后再继续写uboot与kernel的编译,在版本控制下更加宏观地观察每次的变化. 1.在ubuntu ...

  4. git 与 github 最简单的用法

    今天发现cygwin里已经装了git,所以顺便测试一下git是怎么用的. 大概最简单的用法是这样的: 1.在github创建一个repository.复制右边那个 HTTPS clone URL 2. ...

  5. Git学习:如何登陆以及创建本地代码仓库、并提交本地代码至Github(最简单方法)

    在我们的实际开发当中,代码经常会被公司要求上传到网络上,能够大家共同完成一个项目,因此掌握git技能也是一项必不可少的技能了,这里我们来学习以下基本的git操作.首先我们要想使用git这个东西需要把它 ...

  6. 新机git及github sshkey简单配置

    新机git简单配置,毕竟不常用,不用每次都查1.安装gitwindows:https://git-scm.com/download/winubuntu: apt install git 2.全局配置 ...

  7. git与github的简单使用教程

    git与github的简单使用教程 一.创建仓库 点击new,进入创建仓库页面 对将要创建的仓库进行一些简单的设置 最后再点击create repository就可以了. 到这我们就创建好了一个仓库. ...

  8. git链接GitHub命令及基本操作

    Git是一款不错的代码管理工具,下面引用百科的一段话:  Git是用于Linux内核开发的版本控制工具.与CVS.Subversion一类的集中式版本控制工具不同,它采用了分布式版本库的作法,不需要服 ...

  9. Git 的深入理解与GitHub托管服务(转)

    源代码管理系统(SCM)与版本控制   版本控制是一种记录若干文件内容变化,以便将来查阅特定版本修订情况的系统.   本地版本控制系统   许多人习惯用复制整个项目目录的方式来保存不同的版本,或许还会 ...

随机推荐

  1. css padding在ie7、ie6、firefox中的兼容问题

    padding 简写属性在一个声明中设置所有内边距属性. 说明这个简写属性设置元素所有内边距的宽度,或者设置各边上内边距的宽度.行内非替换元素上设置的内边距不会影响行高计算:因此,如果一个元素既有内边 ...

  2. 20个非常绚丽的 CSS3 特性应用演示

    这篇文章收集了20个非常绚丽的 CSS3 效果应用演示,这些示例演示了 CSS3 各种新特性的强大能力.随着越来越多的浏览器对 CSS3 支持的不断完善,设计师和开发者们有了更多的选择,以前需要使用  ...

  3. MySQL 视图知识点小结

    视图本身是一个虚拟表,不存放任何数据.在使用SQL语句访问视图的时候,它返回的数据是MySQL从其他表中生成的.视图和表在同一个命名空间, MySQL在很多地方对于视图和表是同样对待的.不过视图和表也 ...

  4. JVM内存结构之一--总体介绍

    Java 虚拟机在执行Java程序的时候会把它管理的内存区域划为几部分,这一节我们就来解析一下Java的内存区域. 有的人把JVM管理的内存简单地分为堆内存和栈内存,这样分未免有些太肤浅了. Java ...

  5. 黑盒测试用例设计方法&理论结合实际 -> 因果图法

    一. 概念 因果图法是一种利用图解法分析输入的各种组合情况,从而设计测试用例的方法,它适合于检查程序输入条件的各种组合情况 二. 因果图法的应用 等价类划分法和边界值分析方法都是着重考虑输入条件,但没 ...

  6. 《Oracle Database 12c DBA指南》第二章 - 安装Oracle和创建数据库(2.2 安装数据库软件)

    当前关于12c的中文资料比较少,本人将关于DBA的一部分官方文档翻译为中文,很多地方为了帮助中国网友看懂文章,没有按照原文句式翻译,翻译不足之处难免,望多多指正. 2.2 安装数据库软件 这部分简短讲 ...

  7. CodeForce---Educational Codeforces Round 3 The best Gift 解题报告

    对于这题笔者认为可以用数学排列来算,但是由于笔者很懒所以抄了一段大神的代码来交个大家了, 这位大神的基本想法就是通过记录各类书的数量,再暴力破解: 下面贴出这位大神的代码吧: #include< ...

  8. NOIP2010 引水入城

    4引水入城 题目描述 在一个遥远的国度,一侧是风景秀美的湖泊,另一侧则是漫无边际的沙漠.该国的行政区划十分特殊,刚好构成一个N 行M 列的矩形,如上图所示,其中每个格子都代表一座城市,每座城市都有一个 ...

  9. Android Binder------ServiceManager启动分析

    ServiceManager启动分析   简述: ServiceManager是一个全局的manager.调用了Jni函数,实现addServicew getService checkService ...

  10. openstack python sdk list tenants get token get servers

    1,openstack python sdk 获取token 获取租户tenants projects #!/bin/bash export OS_PROJECT_DOMAIN_ID=default ...