我的github搭建过程遇到的问题及解决方法 - Go语言中文社区

我的github搭建过程遇到的问题及解决方法


首先参考:http://callmepeanut.blog.51cto.com/7756998/1304912

一、注册一个GitHub账号

地址:https://github.com/


二、新建一个仓库

每次向GitHub提交的代码都会被放到一个仓库(repo)。为了把你的项目放到GitHub上,你需要有一个GitHub仓库来“入住”。

点击新仓库

184803281.png

在新的页面里填上仓库的名称(因为已经创建过了,所以为提示冲突):

184758220.png

点击创建后就OK了!

184801312.png

三、安装和配置git

使用yum安装

1
yum -y install git

完成后查看是否成功

1
2
[root@localhost ~]# git --version
git version 1.7.1

可以看到安装成功了,如果使用源码可以安装最新版本的。

接着就要设置用户名和Email了,Email最好和注册时候的一样。

1
2
3
4
$ git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit
$ git config --global user.email "your_email@example.com"
# Sets the default email for git to use when you commit

上面的内容都写在配置文件~/.gitconfig里了

恭喜,到这里,基本Git和GitHub都配置好了!


四、创建和提交项目

这里给官方提供的例子吧,Hello-World为项目名称。

1
2
3
4
5
6
7
8
9
mkdir ~/Hello-World
# Creates a directory for your project called "Hello-World" in your user directory
cd ~/Hello-World
# Changes the current working directory to your newly created directory
$ git init
# Sets up the necessary Git files
# Initialized empty Git repository in /Users/you/Hello-World/.git/
touch README
# Creates a file called "README" in your Hello-World directory

如果已经有项目了,就只用切换到项目目录,然后git init。

接着向Git提交修改

1
2
3
4
$ git add *
# Stages your README file, adding it to the list of files to be committed
$ git commit -m 'first commit'
# Commits your files, adding the message "first commit"

这里所有的更改都只是在本地的。Push之后才会提交到GitHub保存:

1
2
3
4
$ git remote add origin https://github.com/username/Hello-World.git
# Creates a remote named "origin" pointing at your GitHub repository
$ git push origin master
# Sends your commits in the "master" branch to GitHub

成功之后就可以在网页上看到添加的文件了:

Your README has been created



可是我的最后一步git push origin master出现问题:

fatal: unable to access 'https://github.com/git/git.git/': SSL certificate problem, verify that the CA cert is OK. Details:  
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed  

 解决方法:CA安全认证错误,安装ca安全认证。

        Setp1:从curl官网下载cacert.pem文件(下载链接参见这里,关于curl的Server SSL Certificates细节参见这里,其中提到,从curl 7.18.0开始,编译安装curl时默认安装ca证书,而我机器的curl version=7.12.1,curl --version可查看):

[plain] view plaincopy
  1. ~$ mkdir ~/tools/https-ca  
  2. ~$ cd ~/tools/https-ca  
  3. ~$ curl http://curl.haxx.se/ca/cacert.pem -o cacert.pem  
        Step2:终端执行下面的命令,以便为git配置ca认证信息:    
[plain] view plaincopy
  1. ~$ git config --global http.sslCAInfo /home/slvher/tools/https-ca/cacert.pem  
        可打开~/.gitconfig确认cainfo配置成功写入git配置文件


执行git push origin master再次出现问题:

error: failed to push some refs to 'git@github.com:dearjohn/tutorial.git'

To prevent you from losing history, non-fast-forward updates were rejected

Merge the remote changes (e.g. 'git pull') before pushing again.  See the

'Note about fast-forwards' section of 'git push --help' for details.

解决方法:github上面已有的README.RM,但是本地没有。引起冲突。


1.本地运行:git pull origin。目的是将本地之前一个版本的代码,与github上保持一致
2.运行gitpush,再将本地代码更新到github上



版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/SprintfWater/article/details/20712531
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-01 21:10:23
  • 阅读 ( 1042 )
  • 分类:Go开源项目

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢