Skip to content

Instantly share code, notes, and snippets.

@alextercete
Last active February 13, 2024 15:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alextercete/cd16fa92bde0088b53277066ee7a1619 to your computer and use it in GitHub Desktop.
Save alextercete/cd16fa92bde0088b53277066ee7a1619 to your computer and use it in GitHub Desktop.

Overcome your fear of Git

Useful shell commands

Create file

touch A

Duplicate file

cp A B

Append line to file

echo "new line" >> A

Show file contents

cat A

Useful Git commands

Show type of an object

git cat-file -t <SHA1>

Show contents of an object

git cat-file -p <SHA1>

Show files in staging area (a.k.a. index)

git ls-files --stage

Useful utilities

Watch for changes in .git/objects

Unix (using entr):

while true; do
  find .git/objects | entr -cd tree .git/objects
done

Windows (using watchexec):

cd .git/objects
watchexec -c -- tree /f

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment