安装Git
ubuntu下
sudo apt-get install git-core
win下
下载地址:https://git-for-windows.github.io/
下载完用Git bash跟Ubuntu差不多了
创建代码仓库
配置身份,这样在提交代码的时候就会知道是谁提交的了
git config --global user.name "your_name"
git config --global user.email "your_email"
可以去掉最后的名字和邮箱查询是否配置成功
创建代码仓库
先cd定位到项目的目录下
然后在这个目录下面输入如下命令
git init
这样就可以记录本地所有的Git操作
提交本地代码
把想要提交的代码添加进来
//add 后面加个点就是提交这个项目的代码文件
git add .
添加完要提交的文件,用以下命令提交
git commit -m "describe_commit_what"
将代码托管到GitHub上
GitHub上创建一个版本库
点击New repository, repository name,public,initialize with README,Apache V2开源协议
把远程版本库克隆到本地
git clone New_repository_Git_web
然后将下载到本地的所有文件,复制到工程目录
执行添加,提交操作
最后将提交的内容同步到GitHub上
git push orign master