November 16, 2020

How to Configure Git for Testing

batou is a configuration management and deployment tool, comparable to Ansible. With batou you can deploy applications, also from git repositories. For this batou uses the git binary - so this has to be tested somehow. One test looks like this… def test_git_remote_init_pull(tmpdir): source = tmpdir.mkdir("source") dest = tmpdir.mkdir("dest") with source.as_cwd(): remote_core.cmd("git init") source.join("foo.txt").write("bar") remote_core.cmd("git add foo.txt") remote_core.cmd("git commit -m bar") remote_core.ensure_repository(str(dest), "git-bundle") remote_core.git_pull_code(str(source), "master") remote_core.git_update_working_copy("master") assert "bar" == dest.join("foo.txt").read() … and worked in some environments, even on Travis, but failed on my Ubuntu box, and later also on GH Actions:...

August 10, 2020

How to Remove a File From a Git Repository but Keep It Locally

For a video project, I have a video folder with videos and subtitle files. Obviously, I do not want to have hundreds of megabytes in my git repository, so I git ignored them - but I committed the subtitles. Now, the videos and the subtitles will be served by nginx from a media directory, outside of the project. In order to delete the subtitles from the git repository, but keep them locally, I have to…...

August 10, 2020

How to Fix an Old Git Commit

… which you do not have pushed to a remote repository. git add <my fixed files> git commit --fixup=OLDCOMMIT git rebase --interactive --autosquash OLDCOMMIT^ via https://twitter.com/nnja/status/796876898005417984?s=03 via https://stackoverflow.com/questions/2719579/how-to-add-a-changed-file-to-an-older-not-last-commit-in-git/27721031#27721031