1.6 KiB
Title | Date | Modified | Author | Category | Tags | Slug | Header_Cover | Summary | Lang |
---|---|---|---|---|---|---|---|---|---|
Some git tricks | 2019-04-22 17:00 | 2019-04-23 14:23 | Fabrice | cheat sheets | git, termtosvg | git-tricks | images/covers/water.jpg | A compilation of some `git` tricks I keep forgetting. | en |
Some git tricks I use from time to time and that I forgot everytime…
Disclaimer: I'm not the perfect git user, and my way of using it is especially crude. Recently, most of my git commits are due to pass, therefore most of those commands are here to fix my own mistakes.
Reset master
to origin/master
:
git checkout origin/master -B master
Jump back and forth from a commit to another (same behaviour as :
git checkout -
Find back lost commits, especially useful when you are doing dirty things and want to cherry-pick
an orphan commit (for instance):
git log --graph --reflog
Some explanations: --graph
show the commit tree, which is useful to notice the orphan leafs, and --reflog
shows the world all the dirtiness you've done.
If you noticed that your folder grows, you can manually cast the garbage collector on it. It should do it automatically, but not often enough according to my standards.
git gc --aggressive
To add changes in an atomic fashion on a file (in an interactive way):
git add -p <file>
Another useful trick is git commit -v
, it allows reviewing your changes before committing.
A ncurse-based interface for git: tig
tig