首页 > 技术文章 > git命令的使用

jiyanjiao-702521 2022-01-04 14:51 原文

git的使用

  • clone远程仓库工程

     cd d:
    cd UIAuto/
     git clone git://172.21.110.0/UITEST.git
    
  • 提交代码到master分支

    git add  .
    git commit -m "本次修改内容"
    git  push origin master
    
  • 把test分支合并到master

    1. 修改test分支代码
    2. 提交test分支代码到test分支
    	git add .
    	git commit -m "提交代码到test分支"
    	git push origin test
    3. 切换到需要合并代码的分支,当前分支为test,切换到master
    	git checkout master
    4. master分支需要pull一下
    	git checkout .
    5. 合并代码
    	git merge test
    	这个时候会出现代码冲突,强制合并为test分支的代码
    	git status 查看状态,以及出现冲突的文件
    	git checkout test <冲突的文件>
    	git checkout test 1.txt  强制合并,把冲突的test代码覆盖到master上来
    6. master提交代码
    	git add .
    	git commit
    	git push origin master
    7. 切换回test分支(保持一个好习惯pull一下)
    	git pull origin  test
    
  • git创建分支

    1. git branch test 创建分支
    2. git checkout test 切换分支
    

参考博客:https://www.cnblogs.com/renfanzi/p/13736353.html#_label0

推荐阅读