essay | tech | year-summary | about
日期:2024-04-30T00:00:00Z
https://stackoverflow.com/question/34100048
# after git v2.27
# this will create a total empty branch
git switch --orphan <new_branch_name>
git commit --allow-empty -m "init mirror commit"
git push -u <mirror_remote> <new_branch_name>
# this will only create a empty branch with existing files
git checkout --orphan <new_branch_name>
git commit --allow-empty -m "init mirror commit"
git push -u <mirror_remote> <new_branch_name>
#! /bin/sh
git checkout <temp-tag> -- <path>
git diff-index --quiet HEAD || git commit
#! /bin/sh
git checkout <temp-tag> -- <path>
git diff-index --quiet HEAD || git commit --amend --no-edit
eg.
#! /bin/sh
git checkout abc22df -- .
git diff-index --quiet HEAD || git commit
after clone with depth 1, if you want a full history, then use unshadow
https://stackoverflow.com/questions/6941889/is-it-safe-to-shallow-clone-with-depth-1-create-commits-and-pull-updates-aga
git clone --depth 1 xxxxxx.repo.git
git pull --unshallow
https://stackoverflow.com/questions/4703200/how-to-delete-remotes-origin-branch
https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely
git branch -d <branch_name>
git branch -D <branch_name>
git branch -r -d origin/MT-2766
git push <remote_name> --delete <branch_name>
git push <remote_name> :<branch_name>
.git/config
[remote "origin"]
url = [email protected]:JingZheCyberSpace/BlaBla.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "candy"]
url = [email protected]:CandyWater/BlaBla.git
fetch = +refs/heads/*:refs/remotes/candywater/*
https://stackoverflow.com/questions/4585929/how-to-use-cp-command-to-exclude-a-specific-directory
rsync -r --verbose --exclude 'exclude_pattern' ./* /to/where/
rsync -r --verbose --exclude ".git" ./aaaa ./bbb
https://stackoverflow.com/questions/10906554/how-do-i-revert-my-changes-to-a-git-submodule
git submodule deinit -f .
git submodule update --init
https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule
git rm <submodule_path>