GitHub入门与实践(2)掌握Git 3、更改提交操作
来源:互联网 发布:淘宝购车靠谱吗 编辑:程序博客网 时间:2024/06/17 19:35
1)回溯历史版本
git reset
$ git reset --hard 899bf3107f38542ea7a8cccc933abb3a420603b8 HEAD is now at 899bf31 Add index $ git checkout -b fix-B Switched to a new branch 'fix-B' $ git add README.md $ git commit -m "Fix B" [fix-B 00a680c] Fix B 1 file changed, 3 insertions(+), 1 deletion(-) $ git reflog 00a680c HEAD@{0}: commit: Fix B 899bf31 HEAD@{1}: checkout: moving from master to fix-B 899bf31 HEAD@{2}: reset: moving to 899bf3107f38542ea7a8cccc933abb3a420603 c86057c HEAD@{3}: merge feature-A: Merge made by the 'recursive' strategy 899bf31 HEAD@{4}: checkout: moving from feature-A to master 3bfe955 HEAD@{5}: checkout: moving from master to feature-A 899bf31 HEAD@{6}: checkout: moving from feature-A to master 3bfe955 HEAD@{7}: commit: Add feature-A 899bf31 HEAD@{8}: checkout: moving from master to feature-A 899bf31 HEAD@{9}: commit: Add index 3f9014e HEAD@{10}: commit (initial): First commit $ git checkout master Switched to branch 'master' $ git reset --hard c86057c HEAD is now at c86057c Merge branch 'feature-A'
2)消除冲突
$ git merge --no-ff fix-B Auto-merging README.md CONFLICT (content): Merge conflict in README.md Automatic merge failed; fix conflicts and then commit the result. $ git add README.md $ git commit -m "Fix conflict" [master 84f9afb] Fix conflict
3)修改提交信息
git commit --amend
$ git commit --amend [master 9c2af5c] Merge branch 'fix-B' $ git log --graph * commit 9c2af5c9e92f9b86916286c83dc0974b7321fab7 |\ Merge: c86057c 00a680c | | Author: Wu Jian <Jamsonwoo@126.com> | | Date: Fri Feb 12 23:58:12 2016 +0800 | | | | Fix conflict | | | * commit 00a680c343207893fff16c26dcbe09c51218f7b3 | | Author: Wu Jian <Jamsonwoo@126.com> | | Date: Fri Feb 12 23:45:47 2016 +0800 | | | | Fix B | | * | commit c86057c4c91d9ae4a841a9e80a1a971194103301 |\ \ Merge: 899bf31 3bfe955 | |/ Author: Wu Jian <Jamsonwoo@126.com> |/| Date: Fri Feb 12 23:27:28 2016 +0800 | | | | Merge branch 'feature-A' | | | * commit 3bfe9559a43f5dd199b0b9b0fac615aabfd7aa8d |/ Author: Wu Jian <Jamsonwoo@126.com> | Date: Fri Feb 12 23:13:24 2016 +0800 | | Add feature-A | * commit 899bf3107f38542ea7a8cccc933abb3a420603b8 | Author: Wu Jian <Jamsonwoo@126.com> | Date: Fri Feb 12 22:42:31 2016 +0800 | | Add index | * commit 3f9014e2b31071d17f6d6d5ce144780a2e0dbf13 Author: Wu Jian <Jamsonwoo@126.com> Date: Fri Feb 12 22:17:23 2016 +0800 First commit
4)压缩历史
git rebase -i
$ git checkout -b feature-C Switched to a new branch 'feature-C' $ git commit -am "Add feature-C" [feature-C 3d7f663] Add feature-C 1 file changed, 1 insertions(+) $ git diff diff --git a/README.md b/README.md index 48f518d..c194c43 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ - feature-A - fix-B - - faeture-C \ No newline at end of file + - feature-C \ No newline at end of file $ git commit -am "Fix typo" [feature-C 07475b3] Fix typo 1 file changed, 1 insertion(+), 1 deletion(-) $ git rebase -i HEAD~2 编辑:pick 改为 fixup [detached HEAD dbf98f4] Add feature-C 1 file changed, 2 insertions(+), 4 deletions(-) Successfully rebased and updated refs/heads/feature-C. $ git log --graph * commit dbf98f40d2c86397774b42e282c13042f2c65559 | Author: Wu Jian <Jamsonwoo@126.com> | Date: Sat Feb 13 00:16:11 2016 +0800 | | Add feature-C | * commit 9c2af5c9e92f9b86916286c83dc0974b7321fab7 |\ Merge: c86057c 00a680c | | Author: Wu Jian <Jamsonwoo@126.com> | | Date: Fri Feb 12 23:58:12 2016 +0800 | | | | Fix conflict | | ...... $ git checkout master Switched to branch 'master' $ git merge --no-ff feature-C Merge made by the 'recursive' strategy. README.md | 1 + 1 file changed, 1 insertions(+)
0 0
- GitHub入门与实践(2)掌握Git 3、更改提交操作
- GitHub入门与实践(2)掌握Git 2、分支操作
- GitHub入门与实践(2)掌握Git 1、基本操作
- GitHub入门与实践(2)掌握Git 6、Git学习资料
- GitHub入门与实践(2)掌握Git 4、推送至远程仓库
- GitHub入门与实践(2)掌握Git 5、从远程仓库获取
- GitHub入门与实践(四)——Git的基本操作从初始化仓库到确认提交是否成功
- GitHub入门与实践学习笔记--github学习基础之关于git的基本操作
- GitHub入门与实践(三)——初步体验Git与GitHub的联动
- GitHub入门与实践
- 《GitHub入门与实践》
- Git与Github入门
- git与github入门
- GitHub入门与实践(一)——在widows环境下安装Git
- git 之 git diff 与 更改提交
- Git入门介绍-3-把本地项目提交到Github
- GitHub入门与实践(二)——初始设置Git,以及在GitHub中添加公开密钥
- Git与Github应用实践
- 1025. 反转链表
- 在腾讯的第二堂产品课——改变大河的流向 梁宁-闲花照水录
- hdu4415 Assassin's Creed
- Leetcode 165. Compare Version Numbers
- 大数据存取的选择:行存储还是列存储?
- GitHub入门与实践(2)掌握Git 3、更改提交操作
- 【伸展树(splay)】[JSOI2008][HYSBZ/BZOJ1014]火星人prefix
- 1秒钟让你了解Hadoop和Spark
- 计算机视觉相关资源
- bootstrap响应式布局学习日记
- linux解压命令
- 河南第六届ACM省赛(Card Trick)
- hibernate异常(2)
- VIM 配置