git reset --hard somecommit

loses its horror when you also get used to

/bin/gitk --reflog

as this is an easy way to see the commit, say a12345678adf, from which you went away. And if the **hard** reset was not that bright after all, just go back again with

git reset --hard a12345678adf

๐Ÿ˜Ž

#git #gitTip

Helpful #git tip of the day ๐Ÿ“ข ๐Ÿค“

If you want to find a particular string (via regex) over all of your commits (be it added, moved or deleted) you can pass the -G option to `git log`.

Example:

git log -G"[Tt]he [Nn]eedle"

Go with -i for case-insensitive match (thank you @nafmo for pointing it out)

โš ๏ธ Warning: There is a similar option with `git log -S --pickaxe-regex`, but it _won't_ show _moved_ lines, only added/deleted lines!

Docs:
https://git-scm.com/docs/git-log#Documentation/git-log.txt--Gregex

#CLI #GitTip #VersionControl

Git - git-log Documentation

In former times I often found it hard to formulate meaningful messages for a #git commit.

Now I usually begin with the file name where the/an important change of this commit happened. Examples:

utils.py: improve logging

test_frontend.py: add failing test for bug #15

core.js: refactoring while working on #15 (wip 3)

Enumerating work-in-progress (wip) commits also helps me. Mostly, I try to commit at least once per hour. Makes me feel safer.

2/x

#GitTip

A neat #programming trick which I do not want to miss anymore:

Whenever I resume to work on a project after some days or weeks I do

git difftool HEAD~1

This displays the changes of the last commit and significantly helps me to pick up my thoughts again.

#git #gittip

(BTW: I have more personal git habits which I am thinking about to share. If this post gets โ‰ฅ 20 boosts/favs I will continue this thread.

EDIT:

Also applies to the reply-posts.
I edit a post to announce a new reply)

1/x

#Git tip

a
main----*
\
\c d
*----*fix
\
\e f
*----*feat

to this
a
main----*
|\
| \c d
| *----*fix
|
\ e f
\*----*feat

$ git switch feat
$ git rebase --onto main fix feat

#GitTip #GitTricks #AsciiArt #Ascii

Looking into how to store things efficiently in #git I came across this SO answer: https://stackoverflow.com/a/8198276

At the end of that answer was this:
`git gc --aggressive`
So I tried that on my local copy of Linus' git repo ... and its size went from 5.1G to 3.4G ๐Ÿ˜ฎ
It takes a bit of time and CPU power, but I just saved 1.7G without throwing anything away ๐Ÿ˜Ž

#GitTip

How does git store files?

I just started learning git and to do so I started reading the Git Community Book, and in this book they say that SVN and CVS store the difference between files and that git stores a snapshot of al...

Stack Overflow

@jb55
#VimTip hashtag? ;-)

(To be consistent, the 'other' one should probably be #GitTip (singular))