git 提交新项目代码到github远程仓库

1 篇文章 0 订阅
1 篇文章 0 订阅


第一步:创建本地新项目

本地项目建好后,名称为: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.


第七步:登录github官网,查查看提交推送情况

第八步:确认,代码同步提交完成

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值