git is hard but time travel in git is easy. PRESENTATION BY MONICA POWELL
@waterproofheart
🔗 www.aboutmonica.com/
Slide 2
Hi, I’m Monica Powell! I’m a Full Stack Engineer at Meetup and organizer of the React Ladies Meetup group. I’ve written about git and other tech adventures in publications such as FreeCodeCamp, Hacker Noon and Code Like A Girl.
@waterproofheart
🔗 www.aboutmonica.com/
Slide 3
Talk Outline 1. Introduction 2. How to write git commits dated in the future 3. Changing the languages that GitHub auto-detects in a repository 4. Automating git workflow 5. Resources
@waterproofheart
🔗 www.aboutmonica.com/
Slide 4
What is git? A distributed version-control system for tracking changes in source code during software development.
@waterproofheart
🔗 www.aboutmonica.com/
Slide 5
What is the relationship between GitHub/BitBucket/GitLab and git??
@waterproofheart
🔗 www.aboutmonica.com/
Slide 6
TIME TRAVEL IN GIT It’s not a bug! It’s a feature. @waterproofheart
🔗 www.aboutmonica.com/
Slide 7
DEBUGGING The marketing mix is a business tool used in marketing and by marketers, originally can be used
@waterproofheart
🔗 www.aboutmonica.com/
Slide 8
CREATE FUTURE COMMIT Checkout new branch Change computer time & replicate issue locally Squash bug and fix issue Commit and push fix Oops!
@waterproofheart
🔗 www.aboutmonica.com/
Slide 9
Is that the only way to commit in the future?
@waterproofheart
🔗 www.aboutmonica.com/
Slide 10
OTHER WAYS TO MODIFY COMMIT DATES
The Date format must follow the Git standard RFC 2822 or ISO 8601. - Can rebase and apply changes commits to the past as well.
@waterproofheart
🔗 www.aboutmonica.com/
Slide 11
What does this look like on GitHub? Write here a list of features, textboxes easy to edit Here you can write more More about your project. Statistics, analysis and content
export GIT_AUTHOR_DATE=”Wed Mar 20 15:12:30 2019 -0700” export GIT_COMMITTER_DATE=”Wed Mar 20 15:12:30 2019 -0700” git commit -m “future commit”
@waterproofheart
🔗 www.aboutmonica.com/
Slide 12
@waterproofheart
🔗 www.aboutmonica.com/
Slide 13
Reclassify Language With One Line of Code
@waterproofheart
🔗 www.aboutmonica.com/
Linguist library “This library is used on GitHub.com to detect blob languages, ignore binary or vendored files, suppress generated files in diffs, and generate language breakdown graphs.” https://github.com/github/linguist#my-repository-isnt-showing-my-la nguage
@waterproofheart
🔗 www.aboutmonica.com/
GIT HOOKS Automate your git workflow
@waterproofheart
🔗 www.aboutmonica.com/
Slide 18
1 TIME TRAVEL IN GIT Build better presentations in less time
@waterproofheart
🔗 www.aboutmonica.com/
Slide 19
1 TIME TRAVEL IN GIT Build better presentations in less time
@waterproofheart
🔗 www.aboutmonica.com/
Slide 20
What is a git hook? Bash scripts that are executed at specific points within the git workflow. precommit, postcommit, prepush, postpush, etc…. Git Hooks Documentation: https://git-scm.com/docs/githooks
@waterproofheart
🔗 www.aboutmonica.com/
Slide 21
Where do they live? Every Git repository has a hidden .git/hooks directory with a script for each hook you can bind to. These can be modified.
@waterproofheart
🔗 www.aboutmonica.com/
Slide 22
How can git hooks be used? ●
Warn when committing to master
●
Run linting and tests before committing
●
Warn or abort when committing code with: console.logs(), sensitive credentials, merge conflict strings or large files.
●
Send notifications after a commit is pushed
●
Sending intl objects to be translated
●
And 1270824+ other ways. @waterproofheart
🔗 www.aboutmonica.com/
Slide 23
Git Hook Package.json Example
@waterproofheart
🔗 www.aboutmonica.com/
Slide 24
Git Hooks Bash Script Example Warn when committing to master Run linting and tests before committing Warn or abort when committing code with: console.logs(), sensitive credentials, merge conflict strings or large file Send notifications after a commit is pushed Sending intl objects to be translated And 1270824+ other ways.
@waterproofheart
🔗 www.aboutmonica.com/
Slide 25
How can git hooks be used?
@waterproofheart
🔗 www.aboutmonica.com/
Slide 26
Limitations of Git Hooks ●
Limited enforcement - can easily be overridden —no-verify or forced pushes
●
Local hooks != shared hooks as .git/hooks not in version control
●
Doesn’t replace CI, server-side branch protection or code reviews
@waterproofheart
🔗 www.aboutmonica.com/