git
Sparse checkouts
Useful when you only need a few files checked out in large repos
git clone -n --depth=1 --filter=tree:0 git@github.com:giantswarm/control-plane-catalog.git
# add the directories you want to work in
git sparse-checkout set --no-cone . oauth2-proxy-3.2.0.tgz-meta/
# checkout the files
git checkout -- oauth2-proxy-3.2.0.tgz-meta/
# make changes, then stage them
git add --sparse oauth2-proxy-3.2.0.tgz-meta/
Search git history for a string)
git log -S <string>
Move commits from main to feature branch
git checkout main
git checkout <commit hash prior to the first one to move>
git checkout -b feature_branch
git rebase main
# or
git cherry-pick <commit hashes to move>
git checkout main
git reset --hard <commit hash used to create initial branch>
Partially revert previous commit
- Revert the commit without committing the change:
git revert -n <commit>
- Edit the files to retain the changes manually, or select the hunks:
git add -p filename.ext