Git

Renaming files with Git

Renaming files can be a bit of a pain as git, by default, is not case sensitive. So if you rename a file you need to run the following command to ensure any case-sensitive changes are picked up

git mv -f test/postman/Pagro-Home-API.postman_collection.json test/postman/pagro-home-api.postman.collection.json

Git aliases

Git has an alias command built in that is cross platform. https://www.git-scm.com/book/en/v2/Git-Basics-Git-Aliases

Git bisect

git bisect is a pretty powerful tool. Say you know there was a bug introduced between 2 commits, you can give it the known good commit and the known bad commit and step through the commits one at a time, running each one against a test script. For example, a jest suite. It is very useful if you don’t know when a bug was introduced and need to identify the commit.

https://makandracards.com/makandra/17477-automated-git-bisect-will-make-your-day

Anecdote about how much time bisect could save you

  1. At my old job, we were building mainline Linux kernels for specific pieces of hardware we supported. There was a bug in the linux kernels intel graphics stack that would occasionally prevent our hardware from booting.
  2. I setup a test script that would run during a bisect, that would build to the device over SSH and reboot it N number of times. If the script was unable to establish an ssh connection within N seconds after a reboot, I had it throw an error.
  3. Using that method I was able to let git bisect run automatically and eventually we found the commit in the linux kernel that broke our hardware and were able to report the bug.

Git describe

Git describe takes the form of:

git describe <ref>

Where <ref> is anything git can resolve into a commit. If you don’t specify a ref, git just uses where you’re checked out right now (HEAD).

The output of the command looks like:

<tag>_<numCommits>_g<hash>

Where tag is the closest ancestor tag in history, numCommits is how many commits away that tag is, and <hash> is the hash of the commit being described.

Git Worktrees

https://git-scm.com/docs/git-worktree

https://levelup.gitconnected.com/git-worktrees-the-best-git-feature-youve-never-heard-of-9cd21df67baf

Look into this some more. Will these be useful in my day to day workflow?

Tags

Installation and configuration

  1. Git - installation
  2. SSH keys
  3. Git - Authentication issues
  4. Git - Configure tooling
  5. Git - Diff And Merge - Settings and Tools
    1. Git - Diff between two branches
  6. Git - logs

Local workflows

  1. Git - local workflow when working with codebases and branches
  2. Git - gitignore file

Working with commits

  1. Git - cherry picking
  2. Git - How to change a commit message
  3. Git - Index, Staging area, adding and removing changes
  4. Git - Pull, Merge and Rebase
  5. Git - Push
  6. Git - Removing sensitive information
  7. Git - stashing
  8. Git - Squashing commits using commands
  9. Git - precommit and prepush hooks
  10. Git - reversing changes
  1. Search a Git repository by commit message or Search the actual content of commits through a repo’s history

Others

  1. Git - Cutting releases from commits
  2. Git - Helpful scripts
  3. Git - Moving around
  4. Git - working with branches
    1. Git - Diff between two branches
  5. Git - Working with forks
  6. Git - working with tags
  7. Git - Migrating code and history from one repository to another
  8. Git - Remove old commit information from a git repository to save space

Links to this note