初始本地仓库推送到远程仓库-git

背景(问题描述)

下面的git的操作符合的情况是:

  • ①本地初始化一个仓库,但是还没有和远程仓库相关联;

  • ②远程仓库也刚刚创建,里面啥也没有

然后目前就想将本地的仓库的内容和远程仓库相关联并推送到远程仓库里面。

1、初始化:

shell 复制代码
86189@LAPTOP-GAHM48A0 MINGW64 /d/start_java/XinQiUtilsOrDemo/restTemplateDemo
$ git init
Initialized empty Git repository in D:/start_java/XinQiUtilsOrDemo/restTemplateDemo/.git/

86189@LAPTOP-GAHM48A0 MINGW64 /d/start_java/XinQiUtilsOrDemo/restTemplateDemo (master)
$ git add .
warning: in the working copy of 'SimpleRestTemplateProject/moduleOne/pom.xml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'SimpleRestTemplateProject/moduleSecond/pom.xml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'SimpleRestTemplateProject/pom.xml', LF will be replaced by CRLF the next time Git touches it

86189@LAPTOP-GAHM48A0 MINGW64 /d/start_java/XinQiUtilsOrDemo/restTemplateDemo (master)
$ git commit -m "add easy demo"
[master (root-commit) ba705e9] add easy demo
 11 files changed, 263 insertions(+)
 create mode 100644 SimpleRestTemplateProject/README.md
 create mode 100644 SimpleRestTemplateProject/moduleOne/pom.xml
 create mode 100644 SimpleRestTemplateProject/moduleOne/src/main/java/com/xinqi/xinqidev/ModuleOneApplication.java
 create mode 100644 SimpleRestTemplateProject/moduleOne/src/main/java/com/xinqi/xinqidev/config/RestTemplateConfiguration.java
 create mode 100644 SimpleRestTemplateProject/moduleOne/src/main/java/com/xinqi/xinqidev/controller/HelloController.java
 create mode 100644 SimpleRestTemplateProject/moduleOne/src/main/resources/application.yml
 create mode 100644 SimpleRestTemplateProject/moduleSecond/pom.xml
 create mode 100644 SimpleRestTemplateProject/moduleSecond/src/main/java/com/xinqi/xinqidev/ModuleSecondApplication.java
 create mode 100644 SimpleRestTemplateProject/moduleSecond/src/main/java/com/xinqi/xinqidev/controller/HelloController.java
 create mode 100644 SimpleRestTemplateProject/moduleSecond/src/main/resources/application.yml
 create mode 100644 SimpleRestTemplateProject/pom.xml

2、配置并推送到最新仓库

shell 复制代码
86189@LAPTOP-GAHM48A0 MINGW64 /d/start_java/XinQiUtilsOrDemo/restTemplateDemo (master)
$ git remote add origin git@gitee.com:flowers-bloom-is-the-sea/rest-template-demo.git

86189@LAPTOP-GAHM48A0 MINGW64 /d/start_java/XinQiUtilsOrDemo/restTemplateDemo (master)
$ git pull origin master --allow-unrelated-histories
From gitee.com:flowers-bloom-is-the-sea/rest-template-demo
 * branch            master     -> FETCH_HEAD
Merge made by the 'ort' strategy.
 README.en.md | 36 ++++++++++++++++++++++++++++++++++++
 README.md    | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 README.en.md
 create mode 100644 README.md

86189@LAPTOP-GAHM48A0 MINGW64 /d/start_java/XinQiUtilsOrDemo/restTemplateDemo (master)
$ git push -u origin master
Enumerating objects: 36, done.
Counting objects: 100% (36/36), done.
Delta compression using up to 8 threads
Compressing objects: 100% (23/23), done.
Writing objects: 100% (35/35), 4.40 KiB | 644.00 KiB/s, done.
Total 35 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To gitee.com:flowers-bloom-is-the-sea/rest-template-demo.git
   a083ace..3fdcf23  master -> master
branch 'master' set up to track 'origin/master'.

3、小结:

shell 复制代码
git init
git add .
git commit -m "first commit"
git remote add origin git_url
git pull origin master --allow-unrelated-histories
git push -u origin master
相关推荐
mister_guo1 天前
开发指南:Git日常维护与常用命令
git
鶴哥只手遮天1 天前
Git 2.56 源码深度剖析:为 Git 3.0 铺路的架构重构
git·开源
小此方1 天前
「插曲:Git」标签管理篇:理解Tag标签、为指定提交打标签、查看标签详情与附注标签
git
Madison-No71 天前
多语言聊天大模型--测试报告
linux·git·python·selenium·jmeter·自动化·postman
小此方1 天前
「插曲:Git」多人协作篇:远程分支创建与关联、多人协作冲突解决、Feature分支开发与合并、git remote prune清理失效分支
git
可乐ea2 天前
Git 基础设施重建:智能体规模开发下的读写解耦
大数据·git·elasticsearch·分布式存储·git基础设施·智能体规模开发·读写解耦
信可维2 天前
AI 说「改完了」怎么确认真改完了:git diff + 测试 + 一张验收表的 3 步复核
人工智能·git
Sun子矜2 天前
Git+Gitee 新手教程精简归纳版
git·gitee
亿道电子Emdoor2 天前
【Perforce】Klocwork-kwgcheck图形化界面无法打开如何解决
git·python·github
小此方3 天前
「插曲:Git」企业规范篇:DevOps开发模型、Git Flow五类分支设计与测试/预发布/生产环境Bug修复及Hotfix紧急发布流程
git·bug·devops