使用git上传代码到GitHub
程序员文章站
2024-03-20 22:06:28
...
阅读本节前请确认两点:a)有GitHub账号;b)本地已成功安装git工具。
Windows键+R调出黑窗口,使用命令上传代码到GitHub仓库。
1.查看git版本
C:\Users\xxx>git --version
git version 2.8.1.windows.1
2.查看git配置
C:\Users\xxx>git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/javasoftwear/Git-2.8.1-64-bit/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
user.name=lankk1
aaa@qq.com
credential.helper=manager
3.进入本地代码目录
C:\Users\xxx>cd C:\gitupload
C:\gitupload>DIR
驱动器 C 中的卷是 OS
卷的***是 9C07-D1DE
C:\gitupload 的目录
2018/07/25 11:06 <DIR> .
2018/07/25 11:06 <DIR> ..
2018/07/25 11:06 <DIR> main
0 个文件 0 字节
3 个目录 105,449,271,296 可用字节
C:\gitupload>
4.将代码所在的目录设置为本地git仓库
C:\gitupload>git init
Initialized empty Git repository in C:/gitupload/.git/
5. 将代码添加至本地git仓库
C:\gitupload>git add . # .表示添加本目录下的所有文件
warning: LF will be replaced by CRLF in main/webapp/WEB-INF/web.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in main/webapp/index.jsp.
The file will have its original line endings in your working directory.
6. 提交到本地git仓库
C:\gitupload>git commit -m 测试用 # 提交,-m后加备注信息
[master (root-commit) 423306b] 测试用
warning: LF will be replaced by CRLF in main/webapp/WEB-INF/web.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in main/webapp/index.jsp.
The file will have its original line endings in your working directory.
7 files changed, 35 insertions(+)
create mode 100644 main/java/demo/lankk1/controller/WebsocketController.java
create mode 100644 main/java/demo/lankk1/service/WebsocketService.java
create mode 100644 main/java/demo/lankk1/service/impl/WebsocketServiceImpl.java
create mode 100644 main/resources/spring/spring-mvc.xml
create mode 100644 main/resources/spring/spring-service.xml
create mode 100644 main/webapp/WEB-INF/web.xml
create mode 100644 main/webapp/index.jsp
7.关联远程仓库
C:\gitupload>git remote add origin https://github.com/lankk1/devOne
C:\gitupload>
8.拾取远程仓库的变化,这样能在提交remote前保持本地和remote的内容一致。
C:\gitupload>git pull origin master
warning: no common commits
remote: Counting objects: 13, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 13 (delta 0), reused 5 (delta 0), pack-reused 8
Unpacking objects: 100% (13/13), done.
From https://github.com/lankk1/devOne
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Merge made by the 'recursive' strategy.
README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 README.md
9.提交给remote仓库
提交时注意要输入账号和密码。
C:\gitupload>git push origin master
Fatal: HttpRequestException encountered.
Fatal: TaskCanceledException encountered.
Username for 'https://github.com': lankk1 # 输入账号
Password for 'https://aaa@qq.com': # 输入密码
Counting objects: 21, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (21/21), 1.75 KiB | 0 bytes/s, done.
Total 21 (delta 0), reused 0 (delta 0)
To https://github.com/lankk1/devOne
d171cdd..0f5731c master -> master
上一篇: 在Python中使用PyMongo操控MongoDB的方法
下一篇: Kotlin中写静态方法