repository working copy staging area objects database the way it keeps REFERENCES directed acyclic graph keeping snapshots traversing graph branches, tags, heads git has 2 mechanisms
-m “third commit” commi!ing folder commit folder file folder folder commit branch HEAD file For more details, refer to book Git Internals by Scott Chacon
/ The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git reset --soft $ git commit --amend / so" reseting cannot be reached Only the cache for the commit you reseted is removed from staging area for your current branch
file folder folder commit branch HEAD file For more details, refer to book Git Internals by Scott Chacon $ git reset --soft $ git commit --amend / so" reseting
file folder folder commit branch HEAD file For more details, refer to book Git Internals by Scott Chacon $ git reset --soft $ git commit --amend / so" reseting
/ The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git reset --mixed mixed reseting cannot be reached entries for commits, files and folders are removed from staging area
/ The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git reset --hard hard reseting cannot be reached removed from staging area removed from working copy
jump to a branch create a branch from a commit create a branch from a tag ANTIPATTERN DANGER $ git checkout feature/PA-121 $ git checkout -b fix/missing-sign-parameter 2449be8 $ git checkout -b hotfix/v1.1 tags/v1 2 BROKEN TIME MACHINE ANTI-PATTERN
2 ORIGIN/master if you branch is pushed already $ git push -f always pull with rebase to get forced pushes securely to rebase your commits and do it o!en!
2 ORIGIN/master if you branch is pushed already $ git push -f Sync source branch a!erwards $ git fetch origin master:master always pull with rebase to get forced pushes securely to rebase your commits and do it o!en!
Pull requests can be used to review code and to validate before merging back to master Scrum tasks are mapped to commits, not stories Github Flow can be used to govern overall TRUNK-BASED DEVELOPMENT let's make git great again Feature flags should be used whenever possible Commit early & o"en perfect later, publish once philosophy Deliver frequently be prepared to send every single commit Deleting branches a"er merge will make your commit graph readable
will...) <subject> # WHY and HOW # Explain why this change is being made # RELATED # Provide links or keys to any relevant issues or other resources # REMEMBER # use lower case in the subject line # start with a verb in imperative tone in the subject line # do not end the subject line with a period # separate subject from body with a blank line # use the body to explain what and why vs. how # can use multiple lines with "-" for bullet points in body $ git config --global commit.template ~/.git-commit-template.txt $ git config --global commit.cleanup strip use git commit templates to create be"er commit messages com t m i F*CKING COMMIT MESSAGES ANTI-PATTERN 9 ANTIPATTERN DANGER
BRANCHES 4. TOO LATE TO VALIDATE 5. CHERRY-PICK OBSSESSION 6. DEATH ON COMMIT GRAPH 7. BUTTON ADDICT 8. TRASH HOUSE 9. OMNIBUS BILL 10. F*CKING COMMIT MESSAGES 11. ZOMBIE REBASE 12. CODE LOSING SYNDROME 13. MESS UP WITH THE ROLLBACK 14. CENTRALIZED GIT 15. MERGE FANATIC 16. BRANCH CEMETERY 17. UNCONTROLLED POWER 18. WEB OF REPOSITORIES 19. ORACLE SYNDROME 20. WAITING FOR HACKERS 21. EVIL MERGE 22. BRANCH OVERDOSE 23. CHUCKY THE COMMAND 24. NO HERO TO SAVE LIVES 25. DUPLICATE COMMITS 26. BIG FAT COMMIT 27. CONFLICT-FOBIA 28. LIVING AT DETACHED HEAD STATE
cecd95914 Note: checking out 'cecd95914'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. LIVING AT DETACHED HEAD STATE ANTI-PATTERN 11 ANTIPATTERN DANGER