首先需要一个github账号,所有还没有的话先去注册吧!
使用git需要先安装git工具,这里给出下载地址,下载后一路直接安装即可:
https://git-for-windows.github.io/
Repository name: 仓库名称
Description(可选): 仓库描述介绍
Public, Private : 仓库权限(公开共享,私有或指定合作者)
Initialize this repository with a README: 添加一个README.md
gitignore: 不需要进行版本管理的仓库类型,对应生成文件.gitignore
license: 证书类型,对应生成文件LICENSE
git add . (注:别忘记后面的.,此操作是把Test文件夹下面的文件都添加进来)
git commit -m “提交信息” (注:“提交信息”里面换成你需要,如“first commit”)
git push -u origin master (注:此操作目的是把本地仓库push到github上面,此步骤需要你输入帐号和密码)
$ git push -u origin master
To https://github.com/OnlyProgram/Spider_Python.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://github.com/OnlyProgram/Spider_Python.git’
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
出现问题的原因:
github中的有些文件不在本地代码目录中
解决办法:
$ git pull --rebase origin master #执行这一步。
结果:
本地代码目录下出现gitHub中文件
此时 再执行以下操作 代码成功上传至github
git push -u origin master