Skip to content

Instantly share code, notes, and snippets.

git filter-repo --email-callback ' return b"new_email_address" if email == b"old_email_address" else email '

Documentation

If git-filter-repo is not installed, you have to install it. git-filter-repo is a program:

  1. Developed by Elijah Newren, who is a veteran contributor to Git.
  2. Endorsed by Git as the replacement for the git-filter-branch program, which had numerous issues.

For reasons that I don't know, it has to be installed separately, instead of being included in a Git distribution. At least this is the case in the version of Git that I'm using.

UPDATE

Although below are methods to extract the contents of a macOS package without actually installing it, the best way might be to create a blank disk image and install the package to this disk image in order to inspect the package contents. To do so:

  • Open the Disk Utility app.
  • Choose "File > New Image > Blank Image". Alternatively, simply press CMD-N.
  • Set the parameters and click on "Save" to create the blank disk image.
  • After creation, it should be already mounted. If not, you can mount it by navigating to the directory that it is placed at and double clicking on the disk image file.
  • Run the package installer by double clicking on the package file.
  • Select this newly created blank disk image as the destination and install it.
  • If the script is preventing you from installing by saying, for example, "macOS isn't installed", you can:

Use the touch command like:

touch -t '1509260825' <path to the file>

This will set both the creation and modification date of the file to "2015-09-26 08.25".

To preserve the creation and modification dates when coping a file, use the -p option of the cp command like:

cp -p <path to the file> <destination path>
@ugultopu
ugultopu / How to create a LinkedIn profile without a phone number?.md
Last active March 3, 2021 20:34
Approaches for creating an account without providing a phone number on web applications that require a phone number only when they think that you are "suspicious"

Summary

If you are reading this article, chances are LinkedIn always asks for a phone number when you attempt to create an account. This means LinkedIn has put your IP address (your "public IP address", which almost surely means the IP address of your Internet router) to a "blacklist". Hence, in order to be able to create a LinkedIn profile without LinkedIn requiring a phone number, you first need to get out of this "blacklist".

To do so, you need to change your IP address. Here, "your IP address" means "your public IP address", which almost surely means the IP address of your Internet router. Hence, you need to access your router and change its IP address. Hence, this is a bit technical and the details depend on your router's make and model.

After getting out of LinkedIn's "blacklist", you need to use a web browser that does not block trackers, scripts, etc. when attempting to create an account. That is, you need to make yourself look as "docile" as possible to LinkedIn.

The safest bet for this is to

@ugultopu
ugultopu / How can the Command Line Tools package not be installed, yet the Command Line Tools still be present on macOS?.md
Created February 18, 2021 12:56
Explanation of how can Command Line Tools on a macOS system can be present, even though the software package of it is missing

Summary

Sometimes, some software updates cause some package "receipts" to disappear (to be removed). This means, even though the package is actually still installed, the receipt for it will be missing. Since the receipt will be missing, one will think that the package is missing too, even though it is actually there.

In other words, this incident of removal of a package receipt without the actual removal of the package essentially disturbs the "integrity" of the native "package system" of macOS.

Details

I had neither Xcode, nor the com.apple.pkg.CLTools_Executables package:

$ pkgutil --pkg-info com.apple.pkg.CLTools_Executables

Summary

Indexing a string with an out-of-bounds index throws an exception, whereas slicing it with out-of-bounds indices simply return an empty string.

Details

In a repository, I came across a code like:

if some_list[some_number:some_number+1] == some_variable:
  • -A: Show all files except the implied . and ...
  • -t: Sort entries by time modified.
  • -r: Reverse the sort order. That is, the last modified file will appear last. This way, even if there are many files, the last modified files will always be in terminal's view, since they will be printed the last.
  • -l: Print output in long format, which prints one entry per line, instead of column format, which is the default when the ls output goes to a terminal.

Summary

Instead of git-rebase, install and use git-filter-repo as follows:

git filter-repo --commit-callback '
new_messages = {
  b"0000000000000000000000000000000000000000": b"Some commit message",
  b"0000000000000000000000000000000000000001": b"Another commit message",
  b"0000000000000000000000000000000000000002": b"Yet another commit message",
  b"0000000000000000000000000000000000000003": b"Still another commit message",

}

Summary

After fixing a merge conflict and adding the fixed file(s) to the index by running git add path-to-the-file when running git-rebase, DON'T RUN git commit --amend. Just run git rebase --continue.

If you run git commit --amend instead of git rebase --continue, the commit in which the conflict occurred will disappear from the commit history. Hence, DON'T run git commit --amend after fixing a merge conflict. Run git rebase --continue.

Details

Let's say that when using git-rebase, you amended a previous commit and you ran git rebase --continue. Let's say that a merge conflict occurred. In this case, git-rebase will pause to let you fix the merge conflict. To fix it, you need to:

  • Go through each conflicted file and edit them to fix them.
  • Add them to the index by running git add path-to-the-file.

Use it as git log --graph --all --oneline.

This shows the abbreviated commit hash and the commit subject on one line, for every ref, in a graph format. The output is colored. Also, if there is a ref associated with a commit, that ref is printed as well.

To make the commit dates show as well, use it as git log --graph --all --pretty=format:"%C(auto)%h %cd%d %s" --date=short. Here, the pretty=format options and their meanings are as follows:

  • %C(auto): Use automatic coloring. Without this option, the whole output is just a single color.
  • %h: Print the abbreviated commit hash.
  • %cd: Print the committer date, which is the date of the commit. This option respects (honors) the value of the --date option.
  • %d: Print the ref name(s) associated with this commit. As far as I understand, d is a reference to the --decorate option of git-log. There is no space between %cd and %d because %d always has a leading space.