win10环境下,首次上传本地代码到gitee(码云)

@创建于:20200330

文章目录

        • 1. 背景
        • 2. 安装git
        • 3. 创建gitee仓库
        • 4. 本地文件上传到gitee的一个test例子
        • 5. 本地工程上传到gitee上
          • 5.1 简化介绍
          • 5.2 详细介绍
        • 6. 参考连接

1. 背景 在win10环境下,第一词把本地代码上传到gitee(码云)个人账户中的一个工程下。
2. 安装git
  • 1、下载安装git:https://git-scm.com/downloads,具体见下面的图
  • 2、安装路径自己选择,页面其他选项默认即可
  • 3、在命令行窗口,使用管理员模式,检验安装是否成功:git --version
C:\Windows\system32>git --version git version 2.23.0.windows.1

参考连接:git代码提交到gitee的步骤一( window)
win10环境下,首次上传本地代码到gitee(码云)
文章图片

win10环境下,首次上传本地代码到gitee(码云)
文章图片

3. 创建gitee仓库
  • 创建gitee账号(如果没有)
  • 创建一个新仓库
win10环境下,首次上传本地代码到gitee(码云)
文章图片
看到下图,说明创建完成了。下图给出了仓库的一些信息。
win10环境下,首次上传本地代码到gitee(码云)
文章图片

参考连接:
  • git上传代码到码云(详细)
  • 怎么将本地项目放到码云(gitee)上面?图文详解
4. 本地文件上传到gitee的一个test例子
  • 本地文件:D:\programs\Anaconda_program\my_test_git
  • gitee创建库:https://gitee.com/username/test_01
  • 对本地文件my_test_git,右击,选择Git Bash Here
    • 安装下面的命令逐一运行;
    • 出现的错误、原因、解决办法都在下面。
username@username MINGW64 /d/programs/Anaconda_program/my_test_git $ git init Initialized empty Git repository in D:/programs/Anaconda_program/my_test_git/.git/username@username MINGW64 /d/programs/Anaconda_program/my_test_git (master) $ git add .username@username MINGW64 /d/programs/Anaconda_program/my_test_git (master) $ git commit -m "my first test" [master (root-commit) 402308e] my first test 1 file changed, 5 insertions(+) create mode 100644 test.pyusername@username MINGW64 /d/programs/Anaconda_program/my_test_git (master) $ git remote add origin https://gitee.com/username/test_01.gitusername@username MINGW64 /d/programs/Anaconda_program/my_test_git (master) $ git push -u origin master To https://gitee.com/username/test_01.git ! [rejected]master -> master (fetch first) error: failed to push some refs to 'https://gitee.com/username/test_01.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.username@username MINGW64 /d/programs/Anaconda_program/my_test_git (master) $ ^C# 上面报错原因:https://gitee.com/XXXX/test_01中有俩文件README.en.md和README.md,本地却没有,所以需要先pull,再push username@username MINGW64 /d/programs/Anaconda_program/my_test_git (master) $ git pull --rebase origin master warning: no common commits remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (4/4), done. From https://gitee.com/username/test_01 * branchmaster-> FETCH_HEAD * [new branch]master-> origin/master First, rewinding head to replay your work on top of it... Applying: my first testusername@username MINGW64 /d/programs/Anaconda_program/my_test_git (master) $ git push origin master Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 4 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 380 bytes | 126.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: Powered by GITEE.COM [GNK-3.8] To https://gitee.com/cXXXXg/test_01.git 95dab75..65dbf69master -> masterusername@username MINGW64 /d/programs/Anaconda_program/my_test_git (master)

参考连接:【已解决】github中git push origin master出错:error: failed to push some refs to
5. 本地工程上传到gitee上 5.1 简化介绍
1、在需要上传的文件夹里,鼠标右键选择Git Bash Here 2、在命令行窗口输入git init初始化,在该文件夹下会自动生成一个.git隐藏目录(创建仓库) 3、接着命令行输入git add . (.表示添加文件夹下所有文件到提交列表) 4、接下来输入git commit -m "注释内容,例如第一次提交"(真正提交到本地仓库) 5、下一步输入git remote add origin https://gitee.com/xxxx/xxxx.git(添加远程仓库) 6、完成之后输入git push -u origin master (把文件同步到远程仓库)

5.2 详细介绍
# 查看下git版本号,这一步可以不做 user@user MINGW64 /d/programs/Anaconda_program/SpiderScrapyd (master) $ git --version git version 2.23.0.windows.1# git init # 初始化,在该文件夹下会自动生成一个.git隐藏目录(创建仓库) user@user MINGW64 /d/programs/Anaconda_program/SpiderScrapyd $ git init Initialized empty Git repository in D:/programs/Anaconda_program/SpiderScrapyd/.git/# $ git add . # .表示添加文件夹下所有文件到提交列表 user@user MINGW64 /d/programs/Anaconda_program/SpiderScrapyd (master) $ git add . warning: LF will be replaced by CRLF in .idea/inspectionProfiles/profiles_settings.xml. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in SpiderScrapyd/app/static/css/animate.css. 上面好多这样的warning# git commit -m "first version" # 提交到本地仓库 user@user MINGW64 /d/programs/Anaconda_program/SpiderScrapyd (master) $ git commit -m "first version" [master (root-commit) 4b5e99f] first version 453 files changed, 76873 insertions(+) create mode 100644 .idea/SpiderScrapyd.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml 每个文件都创建# git remote add origin https://gitee.com/gittee_user_name/SpiderScrapyd.git # 提交到远程仓库 user@user MINGW64 /d/programs/Anaconda_program/SpiderScrapyd (master) $ git remote add origin https://gitee.com/gittee_user_name/SpiderScrapyd.git# git push -u origin master # 把文件同步到远程仓库gitee上 # 会提示你输入账号、密码 user@user MINGW64 /d/programs/Anaconda_program/SpiderScrapyd (master) $ git push -u origin master Enumerating objects: 508, done. Counting objects: 100% (508/508), done. Delta compression using up to 4 threads Compressing objects: 100% (486/486), done. Writing objects: 100% (508/508), 3.17 MiB | 194.00 KiB/s, done. Total 508 (delta 96), reused 0 (delta 0) remote: Resolving deltas: 100% (96/96), done. remote: Powered by GITEE.COM [GNK-3.8] To https://gitee.com/gittee_user_name/SpiderScrapyd.git * [new branch]master -> master Branch 'master' set up to track remote branch 'master' from 'origin'.user@user MINGW64 /d/programs/Anaconda_program/SpiderScrapyd (master)

【win10环境下,首次上传本地代码到gitee(码云)】此时gitee仓库已经含有本地的代码了。
参考连接:在windows使用git提交代码到gitee码云
6. 参考连接
  • git代码提交到gitee的步骤一( window)
  • git上传代码到码云(详细)
  • 怎么将本地项目放到码云(gitee)上面?图文详解
  • 【已解决】github中git push origin master出错:error: failed to push some refs to
  • 在windows使用git提交代码到gitee码云

    推荐阅读