Git建立本地仓库并上传到Gitee的详细步骤

作者:sclibingqing 时间:2023-03-06 20:45:21 

电脑安装git客户端、注册github账号并登陆

到本地项目文件夹右键选择git bash here

Git建立本地仓库并上传到Gitee的详细步骤

输入个人信息(代码提交者)


git config --global user.name "xxxx"

git config --global user.email xxxxx@qq.com

Git建立本地仓库并上传到Gitee的详细步骤

在本地项目目录创建本地仓库

 git init  

输入命令后项目目录会有一个隐藏的.git文件夹

上传所有代码到本地仓库

git add.   (注意add后面有个点,与add之间有一空格)

这样就把代码上传到本地仓库了


git commit -m "initial commit"

Git建立本地仓库并上传到Gitee的详细步骤it

在gitee上新建项目,复制https://gitee.com/xxx/xx.git地址

关联本地仓库并上传代码


git remote add origin https://github.com/Yanyf765/hr_sys.git(上步骤复制的地址)

git push origin master

报错:

Git建立本地仓库并上传到Gitee的详细步骤

执行命令:


git pull origin master --allow-unrelated-histories

Git建立本地仓库并上传到Gitee的详细步骤

git 在pull或者合并分支的时候有时会遇到这个界面。可以不管(直接下面3,4步),如果要输入解释的话就需要:

1.按键盘字母 i 进入insert模式

2.修改最上面那行黄色合并信息,可以不修改

3.按键盘左上角"Esc"

4.输入":wq",注意是冒号+wq,按回车键即可

之后就可以成功的pull,push了

Git建立本地仓库并上传到Gitee的详细步骤

提交到远程报错,如下:

Git建立本地仓库并上传到Gitee的详细步骤

src refspec master does not match any

原因:

本地仓库为空

解决方法:

使用如下命令 添加文件;


$ git add add.php addok.php conn.php del.php edit.php editok.php ftpsql.sql index.php

$ git commit -m "init files"

之后在push过程中出现如下错误:

$ git push -u origin master
Warning: Permanently added the RSA host key for IP address 'xx.xx.xxx.xxx' to the list of known hosts.
To git@github.com:hahaha/ftpmanage.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:hahahah/ftpmanage.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

提示使用 git pull 之后在 push

使用如下命令解决:


$ git pull --rebase origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:hahah/ftpmanage
* branch  master -> FETCH_HEAD
* [new branch] master -> origin/master
First, rewinding head to replay your work on top of it...
Applying: init files

继续push,成功。

Git建立本地仓库并上传到Gitee的详细步骤

来源:https://blog.csdn.net/sclibingqing/article/details/81179470

标签:Git,本地仓库,上传,Gitee
0
投稿

猜你喜欢

  • python 重定向获取真实url的方法

    2022-10-25 03:24:46
  • python生成图片验证码的方法

    2022-07-27 13:39:11
  • asp使用正则自动解析图片地址并保存

    2007-08-17 11:29:00
  • python property的使用技巧分享

    2022-11-18 21:25:51
  • Matplotlib 3D 绘制小红花原理

    2022-11-23 11:53:08
  • python中asyncore异步模块的实现

    2023-10-23 00:50:07
  • Python3逻辑运算符与成员运算符

    2021-03-29 18:59:14
  • 对Python3使运行暂停的方法详解

    2021-02-05 22:55:21
  • python使用NumPy文件的读写操作

    2023-09-27 18:04:44
  • PyTorch基础之torch.nn.Conv2d中自定义权重问题

    2023-10-13 05:16:31
  • python使用xmlrpc实例讲解

    2023-11-25 08:46:59
  • vue使用file-saver本地文件导出功能

    2023-07-02 16:59:26
  • 在python3.5中使用OpenCV的实例讲解

    2021-03-14 21:30:36
  • plt.figure()参数使用详解及运行演示

    2021-11-01 04:52:19
  • win10下python3.5.2和tensorflow安装环境搭建教程

    2022-11-05 15:56:21
  • 在服务端合并和压缩JavaScript和CSS文件

    2010-07-15 12:48:00
  • python 一维二维插值实例

    2022-07-17 10:09:08
  • PHP _construct()函数讲解

    2023-06-14 16:56:43
  • bootstrap手风琴制作方法详解

    2024-04-10 16:20:11
  • mysql执行时间为负数的原因分析

    2024-01-19 12:21:20
  • asp之家 网络编程 m.aspxhome.com