Damien Gonot
Home Blog Notes About

Git

Homepage / Notes / Computer Science / Tools / Git

Commands

Stash

Fixup

git commit --fixup {commit-sha}

Allows to "amend" a commit older than the very last commit

Squash

While a git rebase -i, commits are listed in chronological order (reverse of git log). If you'd like to squash a commit, it has to be in the middle or the bottom, can't be at the top.

Autosquash

git rebase -i --autosquash

Automatically squash fixup-type commits

Submodules

Add a submodule repo to an existing repo: git submodule add {url}

Notice the new .gitmodules file and the submodule repo as a directory

Even though it is a directory in the main repo, git sees it as a particular commit from the submodule repo and doesn't track its content

Resources

https://git-scm.com/book/en/v2/Git-Tools-Submodules

.gitignore

https://git-scm.com/docs/gitignore A .gitignore file lists the files to be ignored by Git. Multiple .gitignore files can be present in the same repo (in subdirectories…).

Tools

CLI tool for a more visual git: https://jonas.github.io/tig/

Resources

(locally) squashing multiple commits using rebase

http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html

https://phoenixnap.com/kb/how-to-rename-git-branch-local-remote

https://myme.no/posts/2023-01-22-git-commands-you-do-not-need.html