• 将已经存在的项目提交到gitlab的新分支中


    将已经存在的项目提交到gitlab中

    在gitlab中新增用户jack

    登录jack这个git用户,然后创建仓库 mxonline

    已经写好了部分功能的项目存放在 D:>cd D:pythonmxonline
    需要推送到gitlab中
    运行git_cmd.exe

    # 切换到项目目录下
    D:>cd D:pythonmxonline

    # 初始化
    D:pythonmxonline>git init
    Initialized empty Git repository in D:/python/mxonline/.git/

    # 加入主分支
    D:pythonmxonline>git remote add origin https://gitlab.example.com/jack/mxonline.git

    D:pythonmxonline>git add .
    warning: LF will be replaced by CRLF in .idea/misc.xml.
    The file will have its original line endings in your working directory
    warning: LF will be replaced by CRLF in .idea/modules.xml.
    The file will have its original line endings in your working directory

    # 提交代码失败
    D:pythonmxonline>git push -u origin master
    To https://gitlab.example.com/jack/mxonline.git
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'https://gitlab.example.com/jack/mxonline.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.

    # 使用账号密码的方式,照样失败
    D:pythonmxonline>git remote set-url origin https://jack:jack2019@gitlab.example.com/jack/mxonline.git

    # 最终的解决办法:
    通过查看提示信息,我发现,是因为本地仓库和远程仓库的文件不一致所致,也就是说,github允许你本地仓库有的东西,远程仓库里没有,但不允许远程仓库有的东西,你本地仓库没有。问题找到了,解决办法就很简单了,那就是在push之前先同步一下本地仓库与远程仓库的文件。使用以下命令

    D:pythonmxonline>git pull --rebase origin master
    From https://gitlab.example.com/jack/mxonline
     * branch            master     -> FETCH_HEAD
     * [new branch]      master     -> origin/master
    First, rewinding head to replay your work on top of it...
    Applying: 'init'

    D:pythonmxonline>git push -f origin master
    Enumerating objects: 1552, done.
    Counting objects: 100% (1552/1552), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (1491/1491), done.
    Writing objects: 100% (1551/1551), 9.44 MiB | 3.46 MiB/s, done.
    Total 1551 (delta 350), reused 0 (delta 0)
    remote: Resolving deltas: 100% (350/350), done.
    To https://gitlab.example.com/jack/mxonline.git
       8c83ef5..5509745  master -> master

    至此,本地代码就推送到了远程仓库的master中

    # 提示warning: LF will be replaced by CRLF in .idea/misc.xml.

    D:pythonmxonline>git add .
    warning: LF will be replaced by CRLF in .idea/misc.xml.
    The file will have its original line endings in your working directory
    warning: LF will be replaced by CRLF in .idea/workspace.xml.
    The file will have its original line endings in your working directory
    # 解决
    D:pythonmxonline>git config --global core.autocrlf false


    # 修改代码后的提交

    D:pythonmxonline>git add .
    D:pythonmxonline>git commit -m "update readme"
    D:pythonmxonline>git -c http.sslVerify=false push origin master


    # 标签

    # 查看标签
    D:pythonmxonline>git tag
    # 命名标签
    D:pythonmxonline>git tag mxonline20191016 -m "拉分支前的备份"
    # 推送标签
    D:pythonmxonline>git push origin mxonline20191016

    # 分支的操作

    # 查看分支
    D:pythonmxonline>git branch
    * master

    # 创建名为 dns_manage的分支
    D:pythonmxonline>git branch dns_manage

    D:pythonmxonline>git branch
      dns_manage
    * master

    # 切换到 dns_manage 分支
    D:pythonmxonline>git checkout dns_manage
    Switched to branch 'dns_manage'
    M       .idea/workspace.xml

    # 修改代码,然后提交到分支中,可以看到git的web界面中就有分支了

    D:pythonmxonline>git add .

    D:pythonmxonline>git commit -m "add dns_manage readme"
    [dns_manage a7efacc] add dns_manage readme
     2 files changed, 21 insertions(+), 14 deletions(-)
     create mode 100644 apps/dns_manage/dns_readme.md

    D:pythonmxonline>git push origin dns_manage
    Enumerating objects: 12, done.
    Counting objects: 100% (12/12), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (7/7), done.
    Writing objects: 100% (7/7), 782 bytes | 78.00 KiB/s, done.
    Total 7 (delta 5), reused 0 (delta 0)
    remote:
    remote: To create a merge request for dns_manage, visit:
    remote:   https://gitlab.example.com/jack/mxonline/merge_requests/new?merge_request%5Bsource_branch%5D=dns_manage
    remote:
    To https://gitlab.example.com/jack/mxonline.git
     * [new branch]      dns_manage -> dns_manage

    # 可以从界面中看到新的分支

  • 相关阅读:
    MySQL Connector Net 6.6.5 Entity Framework 显式预加载 Eager Load Bug
    MySQL 5.6 Replication 复制 FAQ
    MySQL 实现 EF Code First TimeStamp/RowVersion 并发控制
    Linux 系统命令备忘
    MySQL 自增列插入0值的方法
    【转载】将数据存储到SmartObject中
    【转载】使用C#代码发起K2 Blackpearl流程
    【转载】WorkFlow、BPM、SOA
    百度统计喻友平:谈如何更好的优化网站质量
    【转载】浅识K2 blackpearl中SmartObject
  • 原文地址:https://www.cnblogs.com/reblue520/p/11763526.html
Copyright © 2020-2023  润新知