git is hard
have 2 parts: .git/
: where git stuff is stored,
and the 'working tree': a visible, working copy of everything, the files you work on
--recurse-submodules
: include any submodules
--bare
: no working tree,
store the git stuff directly in the directory,
conventionally the dir has the .git
extenstion: repo.git
--template
, or the config init.templateDir
:
copy the non dotfile contents of a directory
git reset --soft $commit
:
uncommit, uncommitted things staged, working directory untouched
(default) git reset --mixed $commit
:
uncommit, uncommitted things unstaged, working directory untouched
git reset --hard $commit
:
uncommit, uncommitted things discarded, working directory changes discarded
binary search through history to find first commit that introduced a change
git bisect start
git bisect (good/old) / (bad/new) / skip
git bisect log / visualize / view
git bisect reset
git bisect replay
: replay the output of git bisect log
and continue where it left offgit bisect run $script
: automate with the use of scriptbranch listing and management
git checkout $branch
: switch to branch, keep uncommitted changes
git checkout -b $branch
: create a new branch
git checkout $branch -- $paths...
: change $paths
to match from $branch
merge changes from $branch onto current branch in a new commit
--squash
: create a new commit with the same effect as a merge
--allow-unrelated-histories
: merge different porjects into one
get and apply remote changes
-r
: rebase local onto remote changes
--autostash
: auto stash and unstash changes
--tags
: push tags
-u
: set upstream
on a clean working tree, apply changes from commits
remove untracked files
-x
: also ignore .gitignored files
-X
: only remove ignored files
-d
: remove directories, also requires -f
ass a new commit changing state to $commit
git stash (push)
: store changes, reset to HEAD
git stash apply
: replay changes
show who last touched each line