当前位置:   article > 正文

将本地新代码推送至 gitee(码云),远程仓库 详细教程_gitee不是开发者也能推送代码

gitee不是开发者也能推送代码

一、注册码

网址: https://gitee.com/

二、新建gitee空仓库 (为推送代码做准备)

2.1 左上角 + 号,新建仓库在这里插入图片描述

2.2 填写仓库信息在这里插入图片描述

2.3 创建完成的仓库

在这里插入图片描述

三、下载安装git客户端

3.1 Git官网下载地址https://git-scm.com/downloads 选择对应的操作系统

在这里插入图片描述

3.2 根据操作系统的位数 选择 一般应该都是64位

Setup --基本版
Portable–便携版
区别:Portable 可以安装在U盘等便携设备上,不会在注册表上留下记录 因此也不会 在右键显示 git Bash here”和“git GUI here”
在这里插入图片描述

3.3 如果下载过慢或无法访问可以使用下载工具下载 如迅雷

(1)网址悬浮右键–>复制链接地址
在这里插入图片描述
(2)打开迅雷 点击新建 一般会自动填充 不自动就自己复制网址到框里 确认下载即可
在这里插入图片描述

3.4 安装git

1.双击git安装程序–> 点击next -->选择安装的路径位置 --> 一路next就可以 最后选择Install 安装 如图安装完毕 点击Finish
在这里插入图片描述
2.右键发现新增 git Bash here”和“git GUI here”,安装完.
在这里插入图片描述

四、将本地代码推送至远程仓库

4.1 进入本地项目目录 右键 git Bash here 进入命令页面

在这里插入图片描述

4.2 配置全局的用户名及邮箱

$ git config --global user.name "xxx"
$ git config --global user.email "xxx"
  • 1
  • 2

4.3 执行 git init 命令 ,初始化本地仓库,把该项目变成可被git管理的仓库

txl@DESKTOP-DT4R7UO MINGW64 /d/JavaProjects/demo
$ git init
Initialized empty Git repository in D:/JavaProjects/demo/.git/
  • 1
  • 2
  • 3

4.4 执行 git config --global --add safe.directory “*” 将当前的目录设置为安全的存储库

txl@DESKTOP-DT4R7UO MINGW64 /d/JavaProjects/demo
$ git config --global --add safe.directory D:/JavaProjects/demo
  • 1
  • 2

4.5 执行 git add . 添加该项目下的所有文件

txl@DESKTOP-DT4R7UO MINGW64 /d/JavaProjects/demo (master)
$ git add .
warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pom.xml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/main/java/com/example/demo/DemoApplication.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/test/java/com/example/demo/DemoApplicationTests.java', LF will be replaced by CRLF the next time Git touches it
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

4.6 执行 git commit -m ‘*’ 将文件添加到本地仓库

txl@DESKTOP-DT4R7UO MINGW64 /d/JavaProjects/demo (master)
$  git commit -m '本次提交的说明123456'
[master (root-commit) 4c2e63f] 本次提交的说明123456
 15 files changed, 889 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 .mvn/wrapper/MavenWrapperDownloader.java
 create mode 100644 pom.xml
 create mode 100644 src/main/java/com/example/demo/controller/TestController.java
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

4.7 执行 git remote add origin 仓库地址 ,将本地仓库和远程仓库关联

txl@DESKTOP-DT4R7UO MINGW64 /d/JavaProjects/demo (master)
$ git remote add origin https://gitee.com/******/test-demo.git
  • 1
  • 2

4.8 执行 git push -u origin “master” 将本地代码推送至远程仓库

$ git push -u origin "master"
Enumerating objects: 32, done.
Counting objects: 100% (32/32), done.
Delta compression using up to 12 threads
Compressing objects: 100% (23/23), done.
Writing objects: 100% (32/32), 54.46 KiB | 13.62 MiB/s, done.
Total 32 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/***********/test-demo.git
 * [new branch]      master -> master
branch 'master' set up to track 'origin/master'.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

4.9 刷新远程仓库

发现代码已经推送至远程仓库了,至此本地的代码已经推送到远程仓库了,执行命令遇见错误时 按照git给的提示就可以。
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/691800
推荐阅读
相关标签
  

闽ICP备14008679号