Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Keep your GIT history
clean
Tomasz Brodziński
@TomaszBro
Commit message – formating and limitations
First line as summary of changes
● max 50 characters
● begin with a capital letter
● no period at the end
● imperative mood
Detailed description
● empty line
● “what”, “why” not “how”
● wrap at 72 characters
● markup syntax
Examples of good git repositories
● Git (https://github.com/git/git/commits/master)
● Linux kernel (https://github.com/tor...
> git commit --amend
Modifying last commit
Undo last commits
> git reset <commit>
> git reset --hard <commit>
Undo commit
> git revert <commit>
Three-way merge
C1 C5C2
C3 C4
C6
feature
C7
master
Rebasing
C1 C5C2
master
C3 C4
C6
feature
Rebasing
C1 C5C2
master
C6
> git rebase master
C3' C4'
feature
C3 C4
feature
Interactive rebasing
> git rebase -i HEAD~5
Interactive rebasing
modifying commit message
pick a2936e8 commit 1
reword 8f6e450 commit 2
pick dabb0ef commit 3
pick ef5...
Interactive rebasing
editing commit
pick a2936e8 commit 1
pick 4ef5850 new message
edit dabb0ef commit 3
pick ef5a182 comm...
Rebasing
> git rebase --skip
> git rebase --continue
> git rebase --abort
Interactive rebasing
removing commit
pick a2936e8 commit 1
pick 4ef5850 new message
pick dabb0ef commit 3
pick ef5a182 com...
Interactive rebasing
squash commits
pick a2936e8 commit 1
pick 4ef5850 new message
squash a733bfe edited commit
pick 4df80...
Interactive rebasing
fixup commit
pick a2936e8 commit 1
pick e95fadc squashed commit
pick 4df80af commit 5
fixup 865ef03 c...
Interactive rebasing
fixup commit
pick a2936e8 commit 1
fixup 865ef03 commit 6
pick e95fadc squashed commit
pick 4df80af c...
Interactive rebasing
running shell command
pick 37ef6a3 commit 1
pick e95fadc squashed commit
exec make test
pick 4df80af ...
Fixup commit
> git commit --fixup=4df80af
Fixup commit
> git rebase -i --autosquash HEAD~5
pick a2936e8 commit 1
pick e95fadc squashed commit
pick 4df80af commit 5
...
Squash commit
> git commit --squash=a2936e8
Squash commit
> git rebase -i --autosquash HEAD~5
pick a2936e8 commit 1
squash 723de73 squash! commit 1
pick e95fadc squas...
Reflog
> git reflog
8a8fa91 HEAD@{0}: merge branch1: Merge made by the
'recursive' strategy.
ddae7c1 HEAD@{1}: checkout: m...
Reflog
> git reset --hard HEAD@{3}
IDE vs terminal
Git log - filtering
> git log --grep <search>
> git log --before <date>
> git log --after <date>
> git log --author <autho...
Git log - formating
> git log
> git log --oneline
> git log --graph
> git log --decorate
> git log --oneline --graph --dec...
Thank you!
Keep your GIT history clean
Keep your GIT history clean
Keep your GIT history clean
Keep your GIT history clean
Keep your GIT history clean
Keep your GIT history clean
Keep your GIT history clean
Próxima SlideShare
Cargando en…5
×

Keep your GIT history clean

438 visualizaciones

Publicado el

Każdy developer zna Gita lub przynajmniej słyszał o nim. Oferuje on wiele możliwości, które pozwalają na tworzenie pełnej historii kodu w projekcie. Aby jednak historia była przyjazna i przejrzysta, dobrze jest stosować kilka zasad podczas korzystania z Gita. W czasie prezentacji przedstawię te zasady i omówię kilka sposobów na efektywne wykorzystanie tego systemu kontroli wersji do trzymania historii "w ryzach".

Publicado en: Tecnología
  • Inicia sesión para ver los comentarios

Keep your GIT history clean

  1. 1. Keep your GIT history clean Tomasz Brodziński @TomaszBro
  2. 2. Commit message – formating and limitations
  3. 3. First line as summary of changes ● max 50 characters ● begin with a capital letter ● no period at the end ● imperative mood
  4. 4. Detailed description ● empty line ● “what”, “why” not “how” ● wrap at 72 characters ● markup syntax
  5. 5. Examples of good git repositories ● Git (https://github.com/git/git/commits/master) ● Linux kernel (https://github.com/torvalds/linux/commits/master) ● Spring Boot (https://github.com/spring-projects/spring-boot/commits/master)
  6. 6. > git commit --amend Modifying last commit
  7. 7. Undo last commits > git reset <commit> > git reset --hard <commit>
  8. 8. Undo commit > git revert <commit>
  9. 9. Three-way merge C1 C5C2 C3 C4 C6 feature C7 master
  10. 10. Rebasing C1 C5C2 master C3 C4 C6 feature
  11. 11. Rebasing C1 C5C2 master C6 > git rebase master C3' C4' feature C3 C4 feature
  12. 12. Interactive rebasing > git rebase -i HEAD~5
  13. 13. Interactive rebasing modifying commit message pick a2936e8 commit 1 reword 8f6e450 commit 2 pick dabb0ef commit 3 pick ef5a182 commit 4 pick 4df80af commit 5
  14. 14. Interactive rebasing editing commit pick a2936e8 commit 1 pick 4ef5850 new message edit dabb0ef commit 3 pick ef5a182 commit 4 pick 4df80af commit 5
  15. 15. Rebasing > git rebase --skip > git rebase --continue > git rebase --abort
  16. 16. Interactive rebasing removing commit pick a2936e8 commit 1 pick 4ef5850 new message pick dabb0ef commit 3 pick ef5a182 commit 4 pick 4df80af commit 5
  17. 17. Interactive rebasing squash commits pick a2936e8 commit 1 pick 4ef5850 new message squash a733bfe edited commit pick 4df80af commit 5
  18. 18. Interactive rebasing fixup commit pick a2936e8 commit 1 pick e95fadc squashed commit pick 4df80af commit 5 fixup 865ef03 commit 6 pick 4ee98c2 commit 7
  19. 19. Interactive rebasing fixup commit pick a2936e8 commit 1 fixup 865ef03 commit 6 pick e95fadc squashed commit pick 4df80af commit 5 pick 4ee98c2 commit 7
  20. 20. Interactive rebasing running shell command pick 37ef6a3 commit 1 pick e95fadc squashed commit exec make test pick 4df80af commit 5 exec cd subdir; make test pick 4ee98c2 commit 7
  21. 21. Fixup commit > git commit --fixup=4df80af
  22. 22. Fixup commit > git rebase -i --autosquash HEAD~5 pick a2936e8 commit 1 pick e95fadc squashed commit pick 4df80af commit 5 fixup 723de73 fixup! commit 5 pick 4ee98c2 commit 7
  23. 23. Squash commit > git commit --squash=a2936e8
  24. 24. Squash commit > git rebase -i --autosquash HEAD~5 pick a2936e8 commit 1 squash 723de73 squash! commit 1 pick e95fadc squashed commit pick 4df80af commit 5 pick 4ee98c2 commit 7
  25. 25. Reflog > git reflog 8a8fa91 HEAD@{0}: merge branch1: Merge made by the 'recursive' strategy. ddae7c1 HEAD@{1}: checkout: moving from branch1 to master 50465c0 HEAD@{2}: commit: Commit 4 ddae7c1 HEAD@{3}: commit: Commit 3 f15e834 HEAD@{4}: commit: My commit 2 4df80af HEAD@{5}: checkout: moving from master to branch1 4df80af HEAD@{6}: commit (initial): My first commit
  26. 26. Reflog > git reset --hard HEAD@{3}
  27. 27. IDE vs terminal
  28. 28. Git log - filtering > git log --grep <search> > git log --before <date> > git log --after <date> > git log --author <author name> > git log <origin>..<branch>
  29. 29. Git log - formating > git log > git log --oneline > git log --graph > git log --decorate > git log --oneline --graph --decorate
  30. 30. Thank you!

×