-
注册git帐号
-
创建git 仓库
输入仓库名
-
在本地安装git(以centos7 为例)
# yum install git -y
- 配置git的全局变量(这里的name跟email只是在你提交代码的时候会显示的,方便别人知道是谁提交的)
# git config --global user.name "your name"
# git config --global user.email "your_email@youremail.com"
- 查看git配置
[root@VM_0_5_centos studypy]# git config --list
user.name=lieman
user.email=944031246@qq.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/lieman/studypy.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
- 按照git官方的配置输入一下命令就可以成功将本地的git跟远程github仓库连接并上传
echo "# studyxx" >> README.md
git init #在你当前的文件夹中初始化git,会生成.git文件夹里面保存git的一些配置
git add README.md #将README.md这个文件添加到git
git commit -m "first commit" #提交
git remote add origin https://github.com/lieman/studyxx.git #将远程仓库跟本地的git文件夹关联
git push -u origin master #将本地的git推送到远程仓库,下面会要求输入你github的帐号密码,除非你做了ssh免密认证