Git CheatSheet
检出checkout
- git checkout 分支名/标签, 该命令会变成detach 只读状态
git checkout -b|-B <new_branch> [<start point>]基于远程分支名/标签/commit创建新分支
track
1 | git branch --set-upstream-to=origin/my@0.11.2 my@0.11.2 |
wsl只取最新来编译
1 | # 1. 切换到dev分支(若已在dev分支可跳过) |
分支管理branch
- 列出分支
- 仅本地 git branch
- 所有 git branch -a
- 模糊匹配 git branch -a –list
<pattern>
- 删除分支 git branch -d
- 重命名分支
git branch -m [<oldbranch>] <newbranch> - 复制分支
git branch -c [<oldbranch>] <newbranch> - 上游
git branch -u <upstream>) [<branchname>]git branch --unset-upstream [<branchname>]
远程管理
- git remote
- git fetch all / repository url / 本地配置的名称
- git pull -r
更新commit时间
1 | # 改最近1个commit |
token登录
1 | git clone https://x-access-token:your-token@github.com/your-username/your-repo.git |
