Git Usages


This file will list some git non-common cases.

Ignore the committed files

# Add the target files into .gitignore
echo <somefile or folder> >> .gitignore

# Remove the files from the git index (not the actual files in the working dir)
git rm -r --cached .

# Add these removals to the staging area
git add .

# Commit them
git commit -m "Clean up ignored files"

Rewrite email of the history

brew install git-filter-repo
git filter-repo --email-callback '
      if b"old_email@example.com" in email:
          return email.replace(b"old_email@example.com", b"new_email@example.com")
      else:
          return email
  ' --force