git
git config
shell
git config --global user.name "tangzixuan"
git config --global user.email "[email protected]"
git config --global pull.rebase true
ssh-keygen -t rsa -C "[email protected]"
pbcopy < ~/.ssh/id_rsa.pub or cat ~/.ssh/id_rsa.pub //to get public key
git config --global pull.rebase true // 非常有用的basic command
shell
git add .
git commit -m "feat: commit message"
git push / git push -f
git pull origin master // 在sub branch,合并远程主干分支
git stash
git stash apply
git checkout main
git rebase dev
git cherry-pick
git reset --hard
git reset --soft
git revert commitId
git revert HEAD^
git submodule add https://github.com/tangzixuan/develop-template // git submodule使用:父目录添加子目录
git mv develop-template my-project/develop-template // 移动 gitsubmodule 目录, https://stackoverflow.com/questions/4604486/how-do-i-move-an-existing-git-submodule-within-a-git-repository
git submodule update --init --recursive // git submodule初始化:子目录初始化
git submodule sync // 修改子模块地址时用到
# create tag
git tag -a 1.4 -m "my version 1.4"
# push all tag to remote
git push origin 1.0 // https://stackoverflow.com/questions/5195859/how-do-you-push-a-tag-to-a-remote-repository-using-git
git push origin --tags
# 分支检出:巨型仓库检出
git sparse checkout
git merge --abort # The unresolved conflict will be cleared off
git branch | grep -v "master" | xargs git branch -D # delete local branch except master: <https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/delete-all-branches-except-master-main-local-remote>经典notes
- git pull 与 git fetch: https://www.zhihu.com/question/38305012;
- git submodule: https://gist.github.com/gitaarik/8735255; https://zhuanlan.zhihu.com/p/87053283; 修改子模块地址链接;
- git rebase: https://www.freecodecamp.org/chinese/news/the-ultimate-guide-to-git-merge-and-git-rebase/; https://cloud.tencent.com/developer/news/231201;
- git sparse checkout: 巨型monorepo仓库:https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/; https://git-scm.com/docs/git-sparse-checkout;
- git merge: squash/rebase: https://www.jianshu.com/p/ff1877c5864e;
https://stackoverflow.com/questions/2427238/what-is-the-difference-between-merge-squash-and-rebase; - .git directory file:
.git/index.lockfile:
https://stackoverflow.com/questions/9282632/git-index-lock-file-exists-when-i-try-to-commit-but-i-cannot-delete-the-file; https://www.pluralsight.com/guides/understanding-and-using-git's-index.lock-file;