# git-pratice-example2 **Repository Path**: lifake/git-pratice-example2 ## Basic Information - **Project Name**: git-pratice-example2 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 9 - **Created**: 2021-07-22 - **Last Updated**: 2021-08-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Git练习 **请完成下面所有操作,完成后将本地库压缩成git-pratice-example-{你的姓名缩写}.zip** 1. 克隆下列远程库; ``` git clone https://gitee.com/lifake/git-pratice-example.git ``` 2. 修改**本地仓库**的姓名、邮箱配置为你的姓名、邮箱; ``` git config --local user.name '李文竣' git config --local user.email '475749761@qq.com' git config --local --list ``` 3. 用origin库的br1检出一条新的本地br1分支; ``` git checkout -b br1 ``` 4. 配置.gitignore,使得产生以下效果(只用全局或多个ignore配置均可),完成后提交: - 所有的.conf被忽略; - Module1的所有.conf文件除外,不需要忽略; - Module2的Module2Config2.conf文件除外,不需要忽略; - Module3中所有位于conf文件夹里的.conf文件除外,不需要忽略; ``` .idea/ *.conf !/Module1/*.conf !/Module2/Module2Config2.conf !/Module3/../conf/*.conf ``` 5. 在Module1中新建文件Func1f.func,并写上以下内容: ``` 这里是f功能。 ``` 6. 提交改动; ``` git add Module1/Func1f.func git commit -m '开发了f功能' ``` 7. 将远程库origin重命名为origin-example; ``` git remote rename origin origin-example ``` 8. 新增远程库origin-example2,并fetch该远程库: ``` git remote add origin-example2 https://gitee.com/lifake/git-pratice-example2.git git fetch origin-example2 ``` 9. 用origin-example2库的br2检出一条新的本地br2分支; ``` git checkout -b br2 origin-example2/br2 ``` 10. 查看历史,找出改动中带有"echart"的提交; ``` git log -S 'echart' ``` 11. 将br2重置到上一步所找到的提交(工作区的代码保留不要删); ``` git reset c096157 ``` 12. 将重置后的工作区stash起来; ``` git stash -u ``` 13. 用origin-example2库的br3检出一条新的本地br3分支; ``` git checkout -b br3 origin-example2/br3 ``` 14. 利用amend提交,修改br3分支最后提交的提交信息为“优化了功能c的UI”; ``` git commit --amend -m '优化了功能c的UI' ``` 15. 将stash应用到br3分支,并提交; ``` git stash pop git commit -m '开发了e功能' ``` 16. 删除stash; ``` ``` 17. 将origin-example/br4合并到br3,并解决冲突; ``` git merge origin-example/br4 vi Module2/Func2c.func git add Module2/Func2c.func git commit -m '解决冲突' ``` 18. 将br3推送到origin-example的一条新分支:br3-{你的姓名缩写}; ``` git push origin-example br3:br3-lwj ``` 19. 用origin-example2库的b-dev检出一条新的本地dev分支; ``` git checkout -b dev origin-example2/b-dev ``` 20. 对dev分支做一次rebase,以达到以下效果: - “开发需要先提交的g功能”与“开发需要后提交的h功能”,这两个提交调换顺序; - “开发i功能的一半”与“开发i功能的另一半”,这两个提交合并为1个提交,信息为“开发了5号功能”; - “'开发j、k功能”,这个提交拆分为两个提交,信息分别为“'开发j功能”、“'开发k功能”; ``` git log git rebase -i 89ebde2 pick dfd2ee1 开发需要先提交的g功能 pick 48e1b52 开发需要后提交的h功能 pick 99bc14f 开发i功能的一半 squash 562e6dc 开发i功能的另一半 edit 05a25ac 开发j、k功能 git reset HEAD~ git add Module3/Func3j.func git commit -m '开发了j功能' git add Module3/Func3k.func git commit -m '开发了k功能' git rebase --continue ``` 21. 再对dev分支基于origin-example2/b-tester再做一次rebase,如有冲突则解决; ``` git rebase origin-example2/b-tester vi Module1/Func1a.func git add Module1/Func1a.func git rebase --continue ``` 22. 修改Version-status.vers中的1.0为1.1,提交; ``` vi Version-status.vers git add Version-status.vers git commit -m '定版1.1' ``` 23. 将dev分支推送到origin-example2/b-tester-{你的姓名缩写}与origin-example2/b-master-{你的姓名缩写}两条分支; ``` git push origin-example2 dev:b-tester-lwj git push origin-example2 dev:b-master-lwj ``` 24. 在dev分支的最后一个提交打一个标签'V1.1-{你的姓名缩写}'; ``` git tag V1.1-lwj ``` 25. 在信息为“定版1.0”的提交打一个标签'V1.0-{你的姓名缩写}'; ``` git log --grep '定版1.0' git tag V1.0-lwj cdaa214 ``` 26. 推送上述两个标签到origin-example2; ``` git push origin-example2 V1.0-lwj git push origin-example2 V1.1-lwj ```