|
|
|
|
|
by rjtobin
2266 days ago
|
|
Some other Git features that I find super useful, which past colleagues of mine haven't known about (which maybe suggests they are not universally known). git rev-parse branch-name: gets the hash of a branch name, useful for verifying two branches are at the same place (so "git rev-parse HEAD" gets the current hash) The ^ and ~ notations for navigating commits: my_branch^ points to the commit 1 before my_branch, and can be repeated multiple times, ie. my_branch^^^ to get the commit 3 from the top. Likewise the tilda notation allows one to jump a fixed number of commits up: my_branch~10 is the commit 10 above my_branch. git rebase -i HEAD~10: interactively rebase the last 10 commits. Easy way to re-order, squash, drop, and/or edit the commit messages of recent history in a single git command. |
|
The difference is in their numerical notion. ~N means go to my Nth first parent. Where ^N means my Nth parent, which is really only valuable/useful on merge commits (Or more specifically octopus merges that merge more than two commits)
This is why ~ and ^ in the single form mean the same thing.
So, in one mental model of the DAG you can think of ^ as horizontal navigation (Right) and ~ as vertical (Down)