-
Squash commits into a single commit and rebase feature branch onto
upstream/develop
git fetch upstream && git rebase -i $(git merge-base feature_name upstream/develop)
-
Cleanup git repository aggressively
use bfg https://rtyley.github.io/bfg-repo-cleaner/
java -jar bfg.jar --delete-files your_unwanted_files git for-each-ref --format="delete %(refname)" refs/original | git update-ref --stdin git reflog expire --expire=now --all && git gc --prune=now --aggressive git push --force
-
Use git submodule
git config submodule.recurse true # Always use --recurse-submodules for every git command git submodule update --init --recursive # Manual update
-
Prune local branches that no longer exists on remote
git remote prune <remote name such as origin>
-
Checkout to a local branch (create if not exists) that tracks a branch in a different remote.
git remote add <name your remote> git@... # add a remote git fetch --all git checkout -b <local branch name such as <remote name>/<branch name>> <remote name>/<branch name>
Last active
January 26, 2024 13:38
-
-
Save LiutongZhou/b9a5267ba16e47e7eb1226bd69111742 to your computer and use it in GitHub Desktop.
Git Tips
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment