1
|
yum -y install git
|
1
2
|
[root@localhost ~]# git --version
git version
1.7
.
1
|
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
"[email protected]"
# Sets the default email for git to use when you commit
|
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
|
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"
|
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
|
可是我的最后一步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
Setp1:从curl官网下载cacert.pem文件(下载链接参见这里,关于curl的Server SSL Certificates细节参见这里,其中提到,从curl 7.18.0开始,编译安装curl时默认安装ca证书,而我机器的curl version=7.12.1,curl --version可查看):
执行git push origin master再次出现问题:
error: failed to push some refs to '[email protected]: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,但是本地没有。引起冲突。