Homepage / Notes / Computer Science / Tools / Git
git init
git add
git status
git commit -m "commit message"
git push origin {branch}
git checkout -b {branch}
(new: git switch
?)git log -p
lists git commit history with the diff
git show {hash}
show commit {hash}
detailsgit log --grep="{search_term}"
git stash
git stash pop
git stash apply
git stash list
git stash save "message"
(new: git stash push "message"
)git stash pop stash@{2}
git stash show
Full diff: git stash show -p
git stash branch {branch} stash@{1}
git stash drop stash@{1}
git stash clear
git commit --fixup {commit-sha}
Allows to "amend" a commit older than the very last commit
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.
git rebase -i --autosquash
Automatically squash fixup
-type commits
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
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…).
CLI tool for a more visual git: https://jonas.github.io/tig/
http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html