Skip to main content

git常用使用方法

1. 克隆代码

一般克隆

**********************!!!PROTECTION POLICY!!!**********************
Waiting For The Next Deployment, Maybe It Will Be Displayed After That.

带子模块克隆

git clone https://github.com/user00000001/user00000001.github.io.git --recursive

克隆指定分/提交/标签

选项-b可放在clone后面

git clone https://github.com/user00000001/user00000001.github.io.git -b master

快速克隆代码

**********************!!!PROTECTION POLICY!!!**********************
Waiting For The Next Deployment, Maybe It Will Be Displayed After That.

2. 同步代码

一般同步

cd user00000001.github.io
git pull origin master
git push origin master

3. 提交代码

git add .
git commit -m "update. " --signoff
git commit -a # 编辑器交互式 vi/nano终端操作
git commit -a --amend

4. 子模块操作

git clone <repository> --recursive
git submodule add <repository> <path>
git submodule init
git submodule update
git submodule foreach git pull
**********************!!!PROTECTION POLICY!!!**********************
Waiting For The Next Deployment, Maybe It Will Be Displayed After That.

5. 子树操作

# git subtree add -P <prefix> <commit>
git subtree add --prefix=<prefix> <commit>
git subtree add --prefix=<prefix> <repository> <ref>
git subtree pull --prefix=<prefix> <repository> <ref>
git subtree push --prefix=<prefix> <repository> <ref>
git subtree merge --prefix=<prefix> <commit>
git subtree split --prefix=<prefix> [OPTIONS] [<commit>]

6. worktree操作

git worktree list
git worktree add path commit_id
git worktree remove path