第一步:创建本地新项目
本地项目建好后,名称为:boot-principle-learn
第二步:初始化本地项目仓库
# 进入项目根目录,执行:git init
$ git init
Initialized empty Git repository in E:/Git-Code/mycode/boot-principle-learn/.git/
第三步:进入github官网,登录,创建新仓库:boot-principle-learn -> 与本地项目仓库同名
第四步:将本地仓库关联上github远程仓库
$ git remote add origin https://github.com/neiliang/boot-principle-learn.git
第五步:提交本地仓库项目代码
# 第一次提交所有代码,在项目根目录执行:git add . 或者 git add -A
$ git add -A
或者:
$ git add .
如果出现:warning: LF will be replaced by CRLF in HELP.md. 这样的告警,执行:$ git config --global core.autocrlf true
# 查看代码状态
$ git status
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: HELP.md
new file: mvnw
new file: mvnw.cmd
new file: pom.xml
new file: src/main/java/com/learn/application/BootPrincipleLearnApplication.java
new file: src/main/java/com/learn/config/AppConfig.java
new file: src/main/java/com/learn/init/MyWebApplicationInitializer.java
new file: src/main/resources/application.properties
new file: src/test/java/com/learn/application/BootPrincipleLearnApplicationTests.java
new file: "\347\254\224\350\256\260/\347\220\206\350\256\272/boot - \345\256\236\347\216\
# 提交代码到本地仓库
$ git commit -m "第一次提交"
[master (root-commit) 5196311] 第一次提交
10 files changed, 717 insertions(+)
create mode 100644 HELP.md
create mode 100644 mvnw
create mode 100644 mvnw.cmd
create mode 100644 pom.xml
create mode 100644 src/main/java/com/learn/application/BootPrincipleLearnApplication.java
create mode 100644 src/main/java/com/learn/config/AppConfig.java
create mode 100644 src/main/java/com/learn/init/MyWebApplicationInitializer.java
create mode 100644 src/main/resources/application.properties
create mode 100644 src/test/java/com/learn/application/BootPrincipleLearnApplicationTests.java
create mode 100644 "\347\254\224\350\256\260/\347\220\206\350\256\272/boot - \345\256\236\347\216\ 260\345\216\237\347\220\206.txt"
# 再次查看提交状态
$ git status
On branch master
nothing to commit, working tree clean
第六步:将本地仓库更新推送到远程github仓库
$ git push -u origin master - 第一次提交,根据提示输入:用户名和密码
fatal: HttpRequestException encountered.
▒▒▒▒▒▒▒▒ʱ▒▒▒▒
Username for 'https://github.com': neiliang
Counting objects: 28, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (28/28), 9.10 KiB | 490.00 KiB/s, done.
Total 28 (delta 0), reused 0 (delta 0)
To https://github.com/neiliang/boot-principle-learn.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
# 将服务器代码同步到本地,这样本地与远程两个仓库的代码就保持一致了。
$ git pull
Already up to date.