# GitPractise **Repository Path**: fubob/git-practise ## Basic Information - **Project Name**: GitPractise - **Description**: GitPractise git相关的使用测试,包括分支切换,tag,版本提交,合并等等操作 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-17 - **Last Updated**: 2025-10-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GitPractise 用于git的各种命令测试 # learn git branch 参考项目: https://github.com/pcottle/learnGitBranching ```shell # 项目启动 docker run -d -p 50003:80 --name learngitbranching gerain/learngitbranching:1.0.0 # 启动地址 http://localhost:50003/?locale=zh_CN # 项目考试参考答案 https://blog.csdn.net/qq_34519487/article/details/107882290 ``` # Gitflow 测试地址:https://learngitbranching.js.org/?locale=zh_CN&NODEMO= Gitflow(实用):https://www.bilibili.com/video/BV1W3411C72K/?spm_id_from=333.1391.0.0&vd_source=824d8f61906b474c0974b8dce18a69fd # 项目实战 ```shell # 4. 实战开发,先推送到远程分支feature/1,在合并到develop分支 ## 4.1 切换到feature/1分支开发 git checkout feature/1 git add . git commit -m "fea1" git push origin feature/1 ## 4.2 合并代码 ## 可以在界面上发起pull request ## 也可以切换到develop分支,使用代码合并 git checkout develop git merge feature/1 # git pull --rebase=false https://gitee.com/fubob/git-practise.git feature/1 # 如果有冲突 # 手动解决冲突,主要是编辑冲突文件,删除 <<<<<<<、=======、>>>>>>> 标记。 git add . git commit -m "fea1" git push origin develop ``` # 常用命令及问题 ```shell # 常用命令 git branch -r # 查看远程分支(简洁版) ``` ## 问题 ```shell # 1. 远程有feature分支,但是本地是feature/1 ## 方法1:删除远程分支 git push origin --delete feature # 删除远程的 feature 分支 git push -u origin feature/1 # 重新推送 feature/1 ## 方法2: 重命名本地分支 git branch -m feature/1 feat-1 # 重命名本地分支 git push -u origin feat-1 # 推送新分支 ``` ```shell # 2. 本地代码与远程代码冲突,push不成功 git pull --rebase origin develop # 或者merge git pull --rebase=fasle origin develop # 然后再push git add git commit git push origin develop ``` ## 页面pull request代码冲突 - 一是通过webide修改 - 二是通过本地命令修改冲突 ``` git checkout develop git pull --rebase=false https://gitee.com/fubob/git-practise.git feature/4 git push origin develop ``` ![image-20251021205528903](https://p.ipic.vip/w5kv5j.png)