【git】使用git bash上传一个多目录项目到码云的全记录

准备工作:

1.准备好本地目录,这次我选择的是21年秋季的作品PicturesShow,内含5个文件和一个子目录,程序在子目录中。

2.在码云上新建一个项目PicturesShow,并记下其网址 https://gitee.com/heyang78/pictures-show.git

3.如果没有git,到 https://gitforwindows.org/ 下载Git for windows,然后安装好,一路next即可。

之后进入目录C:hygiteepicturesShow,右键点空白处选Git bash,打开Git控制台。

往下就是命令执行过程:

ufo@DESKTOP-82T142Q MINGW64 /c/hy/gitee/picturesShow
$ git init
Initialized empty Git repository in C:/hy/gitee/picturesShow/.git/

ufo@DESKTOP-82T142Q MINGW64 /c/hy/gitee/picturesShow (master)
$ git add *.*

ufo@DESKTOP-82T142Q MINGW64 /c/hy/gitee/picturesShow (master)

$ git add .

ufo@DESKTOP-82T142Q MINGW64 /c/hy/gitee/picturesShow (master)
$ git commit -m "First Commit"
[master (root-commit) 31296c6] First Commit
 8 files changed, 603 insertions(+)
 create mode 100644 2021-08-08_080952.png
 create mode 100644 PicturesShowSrc/setting.txt
 create mode 100644 PicturesShowSrc/src/com/hy/Inlet.java
 create mode 100644 PicturesShowSrc/src/com/hy/ShowGui.java
 create mode 100644 README.md
 create mode 100644 picturesShow.jar
 create mode 100644 run.bat
 create mode 100644 setting.txt

ufo@DESKTOP-82T142Q MINGW64 /c/hy/gitee/picturesShow (master)
$ git remote add origin https://gitee.com/heyang78/pictures-show.git

ufo@DESKTOP-82T142Q MINGW64 /c/hy/gitee/picturesShow (master)
$ git push -u origin master
Enumerating objects: 14, done.
Counting objects: 100% (14/14), done.
Delta compression using up to 4 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (14/14), 380.55 KiB | 15.22 MiB/s, done.
Total 14 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.1]
To https://gitee.com/heyang78/pictures-show.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

ufo@DESKTOP-82T142Q MINGW64 /c/hy/gitee/picturesShow (master)
$

上面的步骤中,"git add .  " 是把子目录带入的关键一句话。

执行 git push -u origin master之后,软件会跳出对话框让你输入用户名密码,按实输入即可,如果git提示你装.net,不要理会,push工作仍会进行。

执行完毕后,刷新码云上项目PicturesShow,看到文件已经推送到其中,说明上传成功了。

 

END

原文地址:https://www.cnblogs.com/heyang78/p/15203620.html