1.初始化项目

git init

2.建立本地仓库和远程仓库的连接

git remote add origin 远程仓库URL

ps:移除git仓库连接可使用 git remote  remove origin

3.将码云上的仓库pull到本地

git pull origin 分支名称

4.创建并切换分支,这里和远程仓库的分支要一致(选择指定推送的分支,使用git branch可以查看分支)

git checkout -b 分支名称

5.将文件加载到暂存区

git add .

ps:add错了可以使用git rm --cached 文件名 删除对应的文件

6.将文件提交到本地仓库(-m 描述信息)

git commit -m "上传说明,资源描述"

7.将本地仓库推送到远程仓库

git push origin 分支名称


yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload
$ git init
Initialized empty Git repository in D:/myProject/IJProjects/git-upload/.git/yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote add origin https://gitee.com/jiang-bing-yang/myprojects/tree/ewellyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git pull origin ewell
remote: [session-18405e8e] 404 not found!
fatal: repository 'https://gitee.com/jiang-bing-yang/myprojects/tree/ewell/' not foundyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git pull origin master
remote: [session-804441a1] 404 not found!
fatal: repository 'https://gitee.com/jiang-bing-yang/myprojects/tree/ewell/' not foundyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git init
Reinitialized existing Git repository in D:/myProject/IJProjects/git-upload/.git/yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote add origin https://gitee.com/jiang-bing-yang/myprojects/branches/ewell
error: remote origin already exists.yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote remove originyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote add origin https://gitee.com/jiang-bing-yang/myprojects/branches/ewellyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git pull origin
remote: [session-ca423186] 404 not found!
fatal: repository 'https://gitee.com/jiang-bing-yang/myprojects/branches/ewell/' not foundyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote remove originyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote add origin https://gitee.com/jiang-bing-yang/myprojectsyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git pull origin ewell
remote: Enumerating objects: 35, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 35 (delta 10), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (35/35), 7.51 MiB | 1.04 MiB/s, done.
From https://gitee.com/jiang-bing-yang/myprojects* branch            ewell      -> FETCH_HEAD* [new branch]      ewell      -> origin/ewellyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git branch
* masteryjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git checkout -b ewell
Switched to a new branch 'ewell'yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$ git branch
* ewellmasteryjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$ git add .
warning: in the working copy of 'ewellMqSdkDemo/EwellMQ/SDKConfig.properties', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/SDKConfig.properties', LF will be replaced by CRLF the next time Git touches ityjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$ git commit -m "ewell sdk java demo"
[ewell 1a478cd] ewell sdk java demo23 files changed, 387 insertions(+)create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/.gitignorecreate mode 100644 ewellMqSdkDemo/EwellMQ/.idea/artifacts/EwellMQ_jar.xmlcreate mode 100644 ewellMqSdkDemo/EwellMQ/.idea/compiler.xmlcreate mode 100644 ewellMqSdkDemo/EwellMQ/.idea/encodings.xmlcreate mode 100644 ewellMqSdkDemo/EwellMQ/.idea/libraries/MQSDK_JAVA.xmlcreate mode 100644 ewellMqSdkDemo/EwellMQ/.idea/misc.xmlcreate mode 100644 ewellMqSdkDemo/EwellMQ/.idea/modules.xmlcreate mode 100644 ewellMqSdkDemo/EwellMQ/.idea/runConfigurations.xmlcreate mode 100644 ewellMqSdkDemo/EwellMQ/EwellMQ.imlcreate mode 100644 ewellMqSdkDemo/EwellMQ/SDKConfig.propertiescreate mode 100644 ewellMqSdkDemo/EwellMQ/lib/MQSDK_JAVA.jarcreate mode 100644 ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/EwellMQ.jarcreate mode 100644 ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/SDKConfig.propertiescreate mode 100644 ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/lib/MQSDK_JAVA.jarcreate mode 100644 ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/running.propertiescreate mode 100644 ewellMqSdkDemo/EwellMQ/out/production/EwellMQ/META-INF/MANIFEST.MFcreate mode 100644 ewellMqSdkDemo/EwellMQ/out/production/EwellMQ/com/yjb/test/MyException.classcreate mode 100644 ewellMqSdkDemo/EwellMQ/out/production/EwellMQ/com/yjb/test/MyTest$1.classcreate mode 100644 ewellMqSdkDemo/EwellMQ/out/production/EwellMQ/com/yjb/test/MyTest.classcreate mode 100644 ewellMqSdkDemo/EwellMQ/running.propertiescreate mode 100644 ewellMqSdkDemo/EwellMQ/src/META-INF/MANIFEST.MFcreate mode 100644 ewellMqSdkDemo/EwellMQ/src/com/yjb/test/MyException.javacreate mode 100644 ewellMqSdkDemo/EwellMQ/src/com/yjb/test/MyTest.javayjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$ git push origin ewell
Enumerating objects: 42, done.
Counting objects: 100% (42/42), done.
Delta compression using up to 8 threads
Compressing objects: 100% (30/30), done.
Writing objects: 100% (41/41), 7.51 MiB | 753.00 KiB/s, done.
Total 41 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.3]
To https://gitee.com/jiang-bing-yang/myprojects1446d31..1a478cd  ewell -> ewellyjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$

常用命令
1.从远程仓库克隆项目到本地
git clone  项目地址

2.初始化本地仓库.
git init             # 创建本地仓库

3.本地仓库与远程仓库关联.
git remote add 仓库名 仓库地址    #  仓库名自定义 例如:origin

4.查看仓库名.
git remote          # 查看远程仓库的仓库名,加-v 查看仓库名和地址

5.更改远程仓库地址.
git remote ser-url 仓库名 仓库地址

6.将文件添加添加到暂存区.
git add .    # . 代表所有,可以指定为具体文件

7.将暂存区中的文件提交到本地仓库.
git commit -m "注说明"

8.查看所有分支.
git branch        # 查看本地分支,加-a查看本地分支和远程分支,结果列表中前面标*标识当前使用分支.

9.创建分支.
git branch 分支名称

10.切换分支.
git checkout 分支名称

11.将本地仓库的文件推到远程仓库.
git push 仓库名 分支名称   # 推送时建议先(pull)更新一下

12.将远程仓库更新到本地.
git pull 仓库名  分支名称

13.修改远程仓库名称
git remote rename 旧名称  新名称

14.查看提交记录
git log

15.回滚提交
#Reset会把后面提交的记录直接删掉
git reset --hard commithash       # 例如:git reset --hard 7b8bcaa0b02959126b923fe554824fa9df1dfd87

16.分支合并到主分支上
git merge 分支名称

常见错误
1.提交缓存区中内容到本地仓库
1.1.报错信息如下:
D:\xx\xx>git commit -m"初始化"

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'admin@DESKTOP-NHBTH4U.(none)')

1.2.报错原因:
出现错误的原因是因为无用户信息
1
1.3.解决方案:
# 1.添加你的邮箱
git config --global user.email "xxxx@qq.com"
# 2 添加你的昵称
git config --global user.name "name"

2.本地仓库提交至远程仓库时
2.1.报错信息如下:
D:\xxx\xxx>git push origin master
To https://gitee.com/xxx/xxx.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/xxx/xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

2.2.报错原因:
    出现错误的主要原因是gitee中的README.md文件不在本地代码目录中

2.3.解决方案:
# 1.合并代码
git pull --rebase origin master
# 2.再次提交
git push origin master

git将本地文件推送到远程仓库相关推荐

  1. git将本地文件推送到远程仓库时报错: error: failed to push some refs to ‘https://gitee.com/no-talent-all-by-hand/dome

    今天使用Git推送本地文件到远程库的时候一直报错 error: failed to push some refs to 'https://gitee.com/no-talent-all-by-hand ...

  2. 使用Git命令将本地文件推送至远程仓库

    使用git命令将本地文件推送至远程仓库 具体操作如下 1. 进入项目文件夹,通过命令 git init把这个目录变成 可以管理的仓库 git init 2. 把文件添加到版本库中,使用命令 git a ...

  3. IDEA使用Git将本地工程推送到远程仓库

    本篇文章介绍一下,IDEA开发工具如何使用Git将本地工程推送到远程仓库,具体步骤如下所示. 目录 (1)创建gitee远程仓库 (2)创建本地工程 (3)初始化本地仓库 (4)提交代码到本地仓库 ( ...

  4. Git将本地项目推送到远程仓库

    第一步:我们需要在自己电脑中创建一个空白文件夹,这个功能就是创建一个本地的版本库. 第二步:进入test文件夹,在根部执行Git Bash Here. 第三步:通过命令git init把这个文件夹变成 ...

  5. git将本地分支推送到远程仓库

    1.先创建本地分支 git branch branchname 2.将文件全部提交到本地仓库 初始化git git init 将文件添加到暂存区 git add .将文件提交到仓库中git commi ...

  6. Git使用及创建本地文件推送到github仓库

    Git使用 一.安装Git 一般我们工作的电脑都是Windows系统,要使用git首先要进行安装.从软件管家或者其他平台找到git的安装包,下载后默认安装即可. 安装成功之后,可以在开始菜单里面找到g ...

  7. 使用git将本地文件上传到远程仓库

    操作步骤 在文件目录下打开Git,在Git中输入以下指令: git init # 本地文件夹会生成.git文件夹 git add . git commit -m 'commit file' 添加远程仓 ...

  8. Git命令,合并分支到master,并提交远程仓库,将本地分支推送到远程仓库

    一.我们已经知道如何从远程仓库clone到本地项目中,接下来我们在开发项目中会为每一个单独的功能建立一个分支,并进入分支, git branch login //创建分支 git checkout l ...

  9. Git本地项目推送到远程仓库

    目录 1.初始化git 2.添加远程地址并给地址起一个别名 3.合并远程代码 4.推送 5.常见问题 6.无法推送 7.查看远程仓库信息 8.拉取与本地不相关的git项目 9.配置ssh公钥 1.初始 ...

最新文章

  1. Transact_SQL
  2. 块状元素、内联元素和内联块状元素
  3. .NET Core 1.0 RC2 历险之旅
  4. hadoop SecondNamenode
  5. 面试中精华,俺自己总结的
  6. linux C语言调用Intel处理器CPUID指令的实例
  7. AutoCAD2008换硬盘后重新激活
  8. mt管理器主题修改教程_华为格式状态栏使用教程
  9. oracle锁表语句执行提示无法终止当前对话_ORACLE LOCK TABLE 无法锁定表?
  10. 小国王(状压dp经典题)
  11. SSM网上书店管理系统毕业设计源码082255
  12. 压敏电阻的作用有哪些?
  13. 满足互动、发出用户民意的BBS论坛
  14. OSChina 周一乱弹 ——强行把她拖到家里洗了个澡
  15. 司科水果o2o_水果o2o系统_生鲜配送水果o2o系统开发
  16. Alien Skin Exposure2023调色滤镜插件RAW后期处理软件
  17. 基于JQData的有效前沿组合及投资组合优化
  18. python随手记自动记账_对着微信说一声,它就能帮你自动记账并归类,小编已上瘾...
  19. 计算机思维在音乐中的应用,“思维导图”在音乐理论教育中的应用.doc
  20. 如何利用期权改进指数投资表现——借鉴海外市场经验

热门文章

  1. 国产AI软件,10年前已出现,Excel表格变软件,用友用户:有救了
  2. Android多线程的几种实现方式
  3. html不间断滚动图片,图片不间断滚动代码(详解)
  4. 视频号未来发展趋势怎样,运营中都有哪些技巧丨国仁网络资讯
  5. java中的.builder()方法实现详解
  6. 二叉树的直径_二叉树直径
  7. 连连看游戏思维拓展(java版)
  8. codevs 1391 伊吹萃香
  9. 西安翻译学院计算机系,西安翻译学院在计算机能力与信息素养赛获三等奖
  10. kubernetes nfs 启动nfs-client-provisioner报错