zoukankan      html  css  js  c++  java
  • git使用

    merge的用法.: 譬如  test分支内容合并到int分支里去

    1. 在test分支里进行更改并且提交到仓管中 git commit 中 

    2. 切换到int分支通过命令

    git merge test int 

    3. 查看信息

     $ git log --graph  --oneline

     解决冲突问题

     1.  现在test上进行更改 ,然后 add 并且 commit 

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /i/Python老男孩视频/day133-Git/11 (test)
    $ vi 111.txt

     $ git add 111.txt

    $ git commit -m "test 添加"

    2. 切换到int环境下进行更改

    $ git checkout int
    Switched to branch 'int'

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /i/Python老男孩视频/day133-Git/11 (int)
    $ vi 111.txt

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /i/Python老男孩视频/day133-Git/11 (int)
    $ git add 111.txt

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /i/Python老男孩视频/day133-Git/11 (int)
    $ git commit -m "int环境下变更"
    [int a52f43b] int环境下变更
    1 file changed, 3 insertions(+)

    3. 进行merge ,然后报错了 

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /i/Python老男孩视频/day133-Git/11 (int)
    $ git merge test int
    Auto-merging 11/111.txt
    CONFLICT (content): Merge conflict in 11/111.txt
    Automatic merge failed; fix conflicts and then commit the result.

    4. 解决冲突 编辑111.txt  ,编辑 成自己想成为的文件

     

     

     

    5.  继续add 111.txt ,然后commit 最后merge

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /i/Python老男孩视频/day133-Git/11 (int|MERGING)
    $ git add .

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /i/Python老男孩视频/day133-Git/11 (int|MERGING)
    $ git commit -m "最终版本"
    [int 4f908ff] “最终版本

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /i/Python老男孩视频/day133-Git/11 (int)
    $ git merge test int
    Already up to date.

    6. 如果想回到merge之前的状态 

    7. 查看合并日志

     

     8.  git push

    创建分支并切换到dev分支:

    git checkout --b dev 

    创建分支:

    git branch dev 

    切换分支 到master

    git checkout master

     git remote命令

    要查看当前配置有哪些远程仓库,可以用 git remote 命令,它会列出每个远程库的简短名字.在克隆完某个项目后,至少可以看到一个名为 origin 的远程库,Git 默认使用这个名字来标识你所克隆的原始仓库:

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /c/22/beijinginlinelearning (master)
    $ git remote add xxxx https://github.com/mengbin0546/test.git   xxx是仓库名称

    NorthK_PC@DESKTOP-HF14RRR MINGW64 /c/22/beijinginlinelearning (master)
    $ git remote -v  #查看远端仓库信息.
    xxxx https://github.com/mengbin0546/test.git (fetch)
    xxxx https://github.com/mengbin0546/test.git (push)

    二、git remote

    为了便于管理,Git要求每个远程主机都必须指定一个主机名。git remote命令就用于管理主机名。

    不带选项的时候,git remote命令列出所有远程主机。

    1.  
       
    2.  
      $ git remote
    3.  
      origin
    4.  
       

    使用-v选项,可以参看远程主机的网址。

    1.  
       
    2.  
      $ git remote -v
    3.  
      origin .com:jquery/jquery.git (fetch)
    4.  
      origin .com:jquery/jquery.git (push)
    5.  

    在当我们输入` git remote add origin https://gitee.com/(github/码云账号)/(github/码云项目名).git `

    就会报如下的错

    fatal: remote origin already exists.  

    翻译过来就是:致命:远程来源已经存在

    此时,我们可以先 git remote -v 查看远程库信息:

    可以看到,本地库已经关联了origin的远程库,并且,该远程库指向GitHub。

    解决办法如下:

    1、先输入$ git remote rm origin(删除关联的origin的远程库)

    2、再输入$ git remote add origin git@github.com:(github名)/(git项目名).git 就不会报错了!

    3、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section 'remote.origin'. 我们需要修改gitconfig文件的内容

    4、找到你的github的安装路径,我的是C:UsersASUSAppDataLocalGitHubPortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8etc

    5、找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!

    记一次我关联远程库遇到的错误

    用了上面的办法我就解决了(  希望能对看到的人有所帮助 )
     

  • 相关阅读:
    1305: Substring
    HDU1272 小希的迷宫 并查集
    1213 How Many Tables 简单的并查集问题
    POJ 3090 Visible Lattice Points 欧拉函数
    9.7——模拟赛
    洛谷——P2657 低头一族
    洛谷—— P1204 [USACO1.2]挤牛奶Milking Cows
    9.6——模拟赛
    洛谷—— P1126 机器人搬重物
    前端 自定义format函数
  • 原文地址:https://www.cnblogs.com/mengbin0546/p/10969403.html
Copyright © 2011-2022 走看看