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
- 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.
- 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.
- 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
Look into this some more. Will these be useful in my day to day workflow?
Tags
Installation and configuration
- Git - installation tips
- Git - Authentication issues
- Git - Configure tooling
- Git - Diff And Merge - Settings and Tools
- Git - logs
- Git - Set up SSH keys
Working with commits
- Git - cherry picking
- Git - How to change a commit message
- Git - Pull, Merge and Rebase
- Git - Push
- Git - Removing sensitive information
- Git - stashing
- Git - Squashing commits using commands
- Git - Staging area, adding and removing commits
Others
- Git - Cutting releases from commits
- Git - precommit hooks
- Git - Helpful scripts
- Git - Moving around
- Git - reversing changes
- Git - working with branches
- Git - Working with forks
- Git - working with tags
- Git - Migrating code from one repository to another
- Git - Remove old commit information from a git repository to save space