• 将未被管理的本地项目推送到码云新建的仓库


    将未被管理的本地项目推送到码云新建的仓库

    参考

    git操作之pull拉取远程指定分支以及push推送到远程指定分支

    git push --help

    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git remote -v
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git remote add gitee https://gitee.com/mozq/learn.git
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git remote -v
    gitee   https://gitee.com/mozq/learn.git (fetch)
    gitee   https://gitee.com/mozq/learn.git (push)
    
    $ git branch -a
    * master
    
    $ git push master
    fatal: The current branch master has no upstream branch.
    To push the current branch and set the remote as upstream, use
    
        git push --set-upstream master master
    
    $ git push --set-upstream master master
    fatal: 'master' does not appear to be a git repository
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
    $ git push gitee master
    remote: Incorrect username or password ( access token )
    fatal: Authentication failed for 'https://gitee.com/mozq/learn.git/'
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git remote add giteeSSL git@gitee.com:mozq/learn.git
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git remote -v
    gitee   https://gitee.com/mozq/learn.git (fetch)
    gitee   https://gitee.com/mozq/learn.git (push)
    giteeSSL        git@gitee.com:mozq/learn.git (fetch)
    giteeSSL        git@gitee.com:mozq/learn.git (push)
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git push giteeSSL master
    To gitee.com:mozq/learn.git
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'git@gitee.com:mozq/learn.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.
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git pull
    fatal: No remote repository specified.  Please, specify either a URL or a
    remote name from which new revisions should be fetched.
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git pull giteeSSL
    warning: no common commits
    remote: Enumerating objects: 3, done.
    remote: Counting objects: 100% (3/3), done.
    remote: Compressing objects: 100% (2/2), done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    From gitee.com:mozq/learn
     * [new branch]      master     -> giteeSSL/master
    You asked to pull from the remote 'giteeSSL', but did not specify
    a branch. Because this is not the default configured remote
    for your current branch, you must specify a branch on the command line.
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git pull giteeSSL master
    From gitee.com:mozq/learn
     * branch            master     -> FETCH_HEAD
    fatal: refusing to merge unrelated histories
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git pull giteeSSL master:master --allow-unrelated-histories
    From gitee.com:mozq/learn
     ! [rejected]        master     -> master  (non-fast-forward)
     
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git pull giteeSSL master --allow-unrelated-histories
    From gitee.com:mozq/learn
     * branch            master     -> FETCH_HEAD
    Auto-merging .gitignore
    CONFLICT (add/add): Merge conflict in .gitignore
    Automatic merge failed; fix conflicts and then commit the result.
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master|MERGING)
    $ git status
    On branch master
    You have unmerged paths.
      (fix conflicts and run "git commit")
      (use "git merge --abort" to abort the merge)
    
    Unmerged paths:
      (use "git add <file>..." to mark resolution)
    
            both added:      .gitignore
    
    no changes added to commit (use "git add" and/or "git commit -a")
    
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master|MERGING)
    $ git add .gitignore
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master|MERGING)
    $ git status
    On branch master
    All conflicts fixed but you are still merging.
      (use "git commit" to conclude merge)
    
    Changes to be committed:
    
            modified:   .gitignore
    
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master|MERGING)
    $ git commit -m "merge"
    [master 3179244] merge
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git log
    commit 317924451f8bfaf5b7747504f7732e9650b7c626 (HEAD -> master)
    Merge: 7ecd369 2ee8f7b
    Author: Mozhuiqiu <1215135027@qq.com>
    Date:   Sun Jan 12 19:35:29 2020 +0800
    
        merge
    
    commit 7ecd369bb178c69e5b15f5a024acd6f3f226bb9a
    Author: Mozhuiqiu <1215135027@qq.com>
    Date:   Sun Jan 12 19:05:45 2020 +0800
    
        gitignore
    
    commit da187c709e864b98222c30b6448c1a79ff2a3e1d
    Author: Mozhuiqiu <1215135027@qq.com>
    Date:   Sun Jan 12 19:04:46 2020 +0800
    
        @ConfigurationProperties 注解使用
    
    commit 2ee8f7bc21e26619dc770c1f401e027758ee8987 (giteeSSL/master)
    Author: 魔有追求 <1215135027@qq.com>
    Date:   Sun Jan 12 18:59:47 2020 +0800
    
        Initial commit
        
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git push
    fatal: No configured push destination.
    Either specify the URL from the command-line or configure a remote repository using
    
        git remote add <name> <url>
    
    and then push using the remote name
    
        git push <name>
    
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git push giteeSSL
    fatal: The current branch master has no upstream branch.
    To push the current branch and set the remote as upstream, use
    
        git push --set-upstream giteeSSL master
        
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git push giteeSSL master
    Counting objects: 65, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (43/43), done.
    Writing objects: 100% (65/65), 61.21 KiB | 0 bytes/s, done.
    Total 65 (delta 4), reused 0 (delta 0)
    remote: Powered by GITEE.COM [GNK-3.8]
    To gitee.com:mozq/learn.git
       2ee8f7b..3179244  master -> master
    
    jie@mozq MINGW64 /d/00/02/mozq_demo (master)
    $ git push giteeSSL master:master
    Everything up-to-date
    

    bug

    当前分支没有与远程分支关联

    出现下面的问题,这个意思是:当前分支没有与远程分支关联。
    因此导致了提交代码失败。
    
    MacBook-Pro-5:web-crm wangxiao$ git push
    fatal: The current branch wangxiao has no upstream branch.
    To push the current branch and set the remote as upstream, use
        git push --set-upstream origin wangxiao
    
    解决方案:
    (1)直接 git push origin wangxiao 推向制定的分支,最强暴的方法。
    (2)正如上面所说关联远程分支。
    
    git push --set-upstream origin wangxiao
    origin 是默认的远程版本库名称
    这样关联有一个好处,以后就不用每次git push都用第(1)种方法。
    

    推送失败

    $ git push
    fatal: No configured push destination.
    Either specify the URL from the command-line or configure a remote repository using
    
        git remote add <name> <url>
    
    and then push using the remote name
    
        git push <name>
    方案:git push  [<repository> [<refspec>…]]
    <repository>
    The "remote" repository that is destination of a push operation. This parameter can be either a URL (see the section GIT URLS below) or the name of a remote
    
    <refspec>
    Specify what destination ref to update with what source object. The format of a <refspec> parameter is an optional plus +, followed by the source object <src>, followed by a colon :, followed by the destination ref <dst>
    
    The object referenced by <src> is used to update the <dst> reference on the remote side. By default this is only allowed if <dst> is not a tag (annotated or lightweight), and then only if it can fast-forward <dst>. By having the optional leading +, you can tell Git to update the <dst> ref even if it is not allowed by default (e.g., it is not a fast-forward.) This does not attempt to merge <src> into <dst>. See EXAMPLES below for details.
    

    发生冲突

    $ git pull giteeSSL master --allow-unrelated-histories
    From gitee.com:mozq/learn
     * branch            master     -> FETCH_HEAD
    Auto-merging .gitignore
    CONFLICT (add/add): Merge conflict in .gitignore
    Automatic merge failed; fix conflicts and then commit the result.
    方案:
    	修改发生冲突的文件,然后提交该文件。合并成功。
    
  • 相关阅读:
    BeanFactory 简介以及它 和FactoryBean的区别
    由kill 和 kill -9 引发的Linux signal 学习
    验证整数和小数的正则表达式
    重构!重构!重构!
    Java常用命令:jps、jstack、jmap、jstat(带有实例教程)
    子网掩码是4个255代表什么?
    常见的访问控制模型 Access Control Policy:RBAC,DAC,MAC,ABAC
    安装驱动
    大话数据治理-01什么是治理,治理什么数据
    提高 nginx 服务器 安全性,稳定性、性能 --经验总结-持续更新
  • 原文地址:https://www.cnblogs.com/mozq/p/12184471.html
Copyright © 2020-2023  润新知