Newer commands
# instead of `git reset HEAD --hard`
git restore .
# instead of git checkout -b branchname
git switch -c branchname
CI/CD
Running code quality measures on pull requests is helpful. By protecting the branch, you can make sure the tests pass before a merge is permitted.
Untracked files
Find untracked files that made their way into the git repo. Useful for CI/CD pipelines and running on pull requests.
if [[ ! -z $(git ls-files -i --exclude-standard) ]]; then exit 1; fi
Credit: How to automate CI checks for PRs in WordPress delivery | Buddy Webinar #15
Check for merge conflicts
! git grep -E \"<<<<<<< |>>>>>>> \" -- './*' ':!buddy.yml' ':!.buddy/*'
Credit: How to automate CI checks for PRs in WordPress delivery | Buddy Webinar #15
Subtree
What it is
- Inject dependency in a subdirectory
- Extract a subdirectory as a separate project
- Solves some of the problems associated with git submodules
Benefits
- No new interface to learn
- Stores as regular commits
- Clean integration points
Other notes
git subtree add --prefix target-folder https://.... main --squash
git ls-remote
allows you to list all symbolic names to know what version was pulled into that commit.
Subtree is not good if you have a lot of constant updates to the dependencies
git subtree split --prefix my/project/ --branch extracted
- splits out entire history of a directory into a new directory
Github Actions
Develop actions locally with act
and Github CLI.
# run the actions in a file called action.yml
gh act -W action.yml
# trigger a pull request and run job-name
gh act pull_request --job 'job-name'