learn git branching网站的题目解答-Main部分

这两天花时间把 Learn Git Branching Main部分的做了一遍。 对理解git分支的使用很有帮助,另外发现git的帮助文档和github的帮助文档都很详细,应该好好读一遍。 答案记录在下面,没用show solution看作者给出的答案,只是简单看了看命令数目是不是和作者的solution一样。

1.1 Introduction to Git Commits

git commit
git commit

1.2 Branching in Git

git branch bugFix
git checkout bugFix

1.3 Merging in Git

git checkout -b bugFix
git commit
git checkout master
git commit
git merge bugFix

1.4 Rebase Introduction

git checkout -b bugFix
git commit
git checkout master
git commit
git checkout bugFix
git rebase master

2.1 Detach yo’ HEAD

git checkout C4

2.2 Relative refs (^)

git checkout C4^

2.3 Relative refs #2 (~)

git branch -f master C6
git branch -f bugFix C0
git checkout C1

2.4 Reversing Changes in Git

git reset local~1
git checkout pushed
git revert pushed

3.1 Cherry-pick Intro

git cherry-pick C3 C4 C7

3.2 Interactive Rebase Intro

git rebase -i master~4 --aboveAll

4.1 Grabbing Just 1 Commit

git checkout master
git cherry-pick C4

4.2 Juggling Commits

git rebase -i caption~2 --aboveAll
git commit --amend
git rebase -i caption~2 --aboveAll
git branch -f master caption

4.3 Juggling Commits #2

git checkout master
git cherry-pick C2
git commit --amend
git cherry-pick C3

4.4 Git Tags

git tag v0 C1
git tag v1 C2
git checkout C2

4.5 Git Describe

git commit

5.1 Rebasing over 9000 times

git rebase master bugFix
git rebase bugFix side
git rebase side another
git rebase another master

5.2 Multiple parents

git branch bugWork master~^2~

5.3 Branch Spaghetti

git checkout one
git cherry-pick C4 C3 C2
git checkout two
git cherry-pick C5 C4 C3 C2
git branch -f three C2


—  原创作品许可 — 署名-非商业性使用-禁止演绎 3.0 未本地化版本 — CC BY-NC-ND 3.0   —