- 在本地项目中,创建三个文件,这是托管到git上必须的:
1.1 .gitignore文件
1.2 README.md 文件
1.3 LICENSE 文件
The MIT License (MIT)
Copyright (c) 2014 connors and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- 安装Git,执行
git init
命令到本地项目。git下载地址 - 执行
git status
命令,可以查看仓库当前的状态。当前我自己的仓库标红的均属于未加入的文件
git add .
命令:添加到暂存
- 再次使用
git status
命令,可以发现和第一次状态不一样。
- 执行
git commit -m "init my project"
命令,如果没有配置过 git,则提示:
- 我们要对此设置 git 全局配置
git config --global user.name "your name"
git config --global user.email "your email"
- 上传代码至码云
git remote add origin https://gitee.com/Yuki-W/vue_practical_project_01.git
git push -u origin master
注册码云账号,创建仓库
-
如果曾经注册过码云,则可以直接忽略这一步。我们如果要将自己编写的代码上传至仓库,则我们需要有自己的仓库,可以是 gitHub仓库,也可以是码云。gitHub是国外的仓库,所以访问速度会稍慢点。我们可以使用码云,这是一个国内的仓库。
-
当我们注册好账号后,首先我们需要设置一个公钥。可以参考此文档:码云生成,添加SSH公钥步骤
10.当我们在创建仓库时,无需设置以下内容,因为我们已经在项目运之处设置了.gitignore
文件、README.md
文件和LICENSE
文件。 -
当我们新创建了一个仓库后,会出现自己的仓库名和邮箱地址,在仓库上传时会要求我们输入用户名和邮箱地址。当我们执行第7步代码后,刷新页面即可看到已上传成功的项目。