分支创建git branch XX分支切换git checkout XX分支创建并切换git checkout -b XX切换上一个分支git checkout –Administrator@User-14 MINGW64 /g/gitdemo (master)$ git branch A//1创建分支A Administrator@User-14 MINGW64 /g/gitdemo (master)$ git branch//分支列表 , 当前分支还是在主分支上A* master Administrator@User-14 MINGW64 /g/gitdemo (master)$ git checkout A//2切换当前分支为ASwitched to branch 'A'Mtest.txt Administrator@User-14 MINGW64 /g/gitdemo (A)$ git branch//分支列表显示当前分支为A* Amaster Administrator@User-14 MINGW64 /g/gitdemo (A)$ git checkout master//切换到主分支上Switched to branch 'master'Mtest.txt ====================Administrator@User-14 MINGW64 /g/gitdemo (master)$ git checkout -b B//创建分支B并切换到BSwitched to a new branch 'B'Mtest.txt Administrator@User-14 MINGW64 /g/gitdemo (B)$ git branch//分支列表显示当前为B分支A* Bmaster Administrator@User-14 MINGW64 /g/gitdemo (B)$ git checkout -//切换上一个分支masterSwitched to branch 'master'Mtest.txt番外:
git checkout master^ 使HEAD指向当前的上一记录 。git checkout master~1 等同上行 。git checkout master~n 使HEAD指向当前的上n条记录处 。分支的删除:git branch -D fname
Administrator@User-14 MINGW64 /g/gitdemo (master)$ git branch -D BDeleted branch B (was 670ec48). Administrator@User-14 MINGW64 /g/gitdemo (master)$ git branch* mastergit branch -f bugFix master 强制bugFix分支指向master
分支的合并:git merge fname
//先要切换到合并后的分支Administrator@User-14 MINGW64 /g/gitdemo (A)$ git branch masterfatal: A branch named 'master' already exists. Administrator@User-14 MINGW64 /g/gitdemo (A)$ git merge AAlready up to date.图形查看日志:git log –graph
Administrator@User-14 MINGW64 /g/gitdemo (master)$ git log --graph* commit d76d79a34d1153c619297dd8fc3013c00cc8f9e8 (HEAD -> master, A)| Author: Administrator <woodlum@vip.qq.com>| Date:Wed Jan 6 15:20:27 2021 +0800||a1|* commit 31a3585df1ebb5b744689ba1b7530c525c4c4271Author: Administrator <woodlum@vip.qq.com>Date:Wed Jan 6 15:19:25 2021 +0800m1五、更改提交的操作回溯历史版本:git reset
//查看操作日志Administrator@User-14 MINGW64 /g/gitdemo (master)$ git reflogd76d79a (HEAD -> master, A) HEAD@{0}: reset: moving to d76d79ad76d79a (HEAD -> master, A) HEAD@{1}: reset: moving to d76d79a31a3585 HEAD@{2}: reset: moving to 31a3585d76d79a (HEAD -> master, A) HEAD@{3}: merge A: Fast-forward31a3585 HEAD@{4}: checkout: moving from A to masterd76d79a (HEAD -> master, A) HEAD@{5}: commit: a131a3585 HEAD@{6}: checkout: moving from master to A31a3585 HEAD@{7}: commit (initial): m1 //回溯到A分支创建之前Administrator@User-14 MINGW64 /g/gitdemo (master)$ git reset --hard 31a3585HEAD is now at 31a3585 m1 //创建B分支Administrator@User-14 MINGW64 /g/gitdemo (master)$ git checkout -b BSwitched to a new branch 'B' //修改文件内容并提交Administrator@User-14 MINGW64 /g/gitdemo (B)$ git add . Administrator@User-14 MINGW64 /g/gitdemo (B)$ git commit -m "b1"[B 69eb4b2] b1 1 file changed, 1 insertion(+), 1 deletion(-) Administrator@User-14 MINGW64 /g/gitdemo (B)$ git reflog69eb4b2 (HEAD -> B) HEAD@{0}: commit: b1//提交B分支的修改31a3585 (master) HEAD@{1}: checkout: moving from master to B//创建B分支并切换31a3585 (master) HEAD@{2}: reset: moving to 31a3585//回溯到A分支之前d76d79a (A) HEAD@{3}: reset: moving to d76d79ad76d79a (A) HEAD@{4}: reset: moving to d76d79a31a3585 (master) HEAD@{5}: reset: moving to 31a3585d76d79a (A) HEAD@{6}: merge A: Fast-forward31a3585 (master) HEAD@{7}: checkout: moving from A to masterd76d79a (A) HEAD@{8}: commit: a131a3585 (master) HEAD@{9}: checkout: moving from master to A31a3585 (master) HEAD@{10}: commit (initial): m1 //推进到分支A合并到master位置Administrator@User-14 MINGW64 /g/gitdemo (master)$ git reset --hard d76d79aHEAD is now at d76d79a a1冲突消除
//前面已经合并了A分支 , 现在合并B分支 , 会发现更改部分冲突Administrator@User-14 MINGW64 /g/gitdemo (master)$ git merge BAuto-merging test.txtCONFLICT (content): Merge conflict in test.txtAutomatic merge failed; fix conflicts and then commit the result. Administrator@User-14 MINGW64 /g/gitdemo (master|MERGING)$将test文件修改为想要提交的内容 , 然后add和commit即可
以上关于本文的内容,仅作参考!温馨提示:如遇健康、疾病相关的问题,请您及时就医或请专业人士给予相关指导!
「四川龙网」www.sichuanlong.com小编还为您精选了以下内容,希望对您有所帮助:- 抖音上传视频时间多久 抖音发视频长时间是多少
- 为什么上传头像失败:手机上传报名照片失败,常见问题及解决方法总结
- 给文件夹直接加密步骤 怎么给磁盘加密码
- 缓存视频合并工具app推荐 苹果手机缓存变成本地视频
- 字体在电脑c盘的位置 电脑里的字体一般文件夹在哪里
- 苹果用户都艳羡的功能?ColorOS 12属实把本地化服务玩明白了
- 办公室两台电脑共享文件的方法 电脑共享文件夹无法访问
- 共享服务器搭建方案 公司共享文件夹的建立
- 教你查看电脑中的隐藏文件 win7打开隐藏的文件夹
- 前端获取上传文件路径 formdata上传文件附加参数