Here is the talk CB Bailey and I did at ACCU Conference 2019. This was the first talk I have done with someone else, and I really enjoyed it:
Category: git
Deleting commits from the git history
Today I wanted to fix a Git repo that contained some bad commits (i.e. git fsck complained about them). [I wanted to do this because GitLab was not allowing me to push the bad commits.]
I wanted the code to look exactly as it did before, but the history to look different, so the bad commits disappeared, and (presumably) the work done in the bad commits to look like it was done in the commits following them.
Here’s what I ran:
git filter-branch -f --commit-filter ' if [ "${GIT_COMMIT}" = "abdcef012345abcdef012345etcetcetc" ]; then echo "Skipping GIT_COMMIT=${GIT_COMMIT}" >&2; skip_commit "$@"; else git commit-tree "$@"; fi ' --tag-name-filter cat -- --all
(Where abdcef012345abcdef012345etcetcetc was the ID of the commit I wanted to delete.)
Of course, you can make this cleverer to exclude multiple commits at a time, or run this several times, putting in the right commit ID each time.
“git what” is “git status” on steroids
For when git status is not enough, I wrote git what:
If you often have a few branches on the go, it could be useful.
New open source project on work time – git-history-data
Announcing a little open source project that I have built at work and been allowed to publish Freely.
git-history-data analyses a Git source code repository and dumps out data in a form that is easy to analyse.
I wrote an article demonstrating how to use it to find out some interesting information about the codebase of Git itself and got it published on IBM DeveloperWorks Open: Learning about the Git codebase using git-history-data.
Using GitHub and GitLab
Taking all the Git understanding we’ve developed through the series on Git and applying it to how to work on and contribute to projects on GitHub and similar systems like GitLab: