上传本地项目代码到Gitee或Github

1、登录Gitee创建一个与项目名字相同的仓库,如book
在这里插入图片描述
2、打开Git命令窗口Git Bash
在这里插入图片描述
3、切换到项目的目录,如E:\workspace\mybatis-spring\book
在这里插入图片描述
4、执行以下命令

# 1、初始化
$ git init
Initialized empty Git repository in E:/workspace/mybatis-spring/book/.git/
# 2、添加远程仓库
$ git remote add origin https://gitee.com/moss_huang/book.git

# 3、同步远程仓库到本地仓库
$ git pull origin master
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://gitee.com/moss_huang/book
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master

# 4、添加要上传的文件到缓存区
$ git add . 或者 git add + 文件名
warning: LF will be replaced by CRLF in book.sql.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in logs/book.log.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/main/webapp/WEB-INF/js/bootstrap.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/main/webapp/WEB-INF/js/jquery-3.3.1.min.js.
The file will have its original line endings in your working directory

# 5、上传代码到本地仓库
$ git commit -m '测试上传代码'

# 6、将本地仓库推送到远程仓库
$ git push origin master
Enumerating objects: 66, done.
Counting objects: 100% (66/66), done.
Delta compression using up to 4 threads
Compressing objects: 100% (49/49), done.
Writing objects: 100% (65/65), 81.20 KiB | 2.54 MiB/s, done.
Total 65 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-3.8]
To https://gitee.com/moss_huang/book.git
   dd98d95..389971a  master -> master

5、刷新Gitee就可以看到提交的项目了
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章