上傳本地項目代碼到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就可以看到提交的項目了
在這裏插入圖片描述

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