Git相关

origin, main, master, 分别是什么又有什么关系

  • origin:远程仓库的名称(默认远程仓库的别名)。
  • main:现代 Git 项目中用于表示主分支的名称,通常是默认分支。
  • master:旧版本 Git 中的默认主分支名称,已经被很多项目替换为 main

怎么创建新分支

1
2
3
git branch branch-player
git checkout branch-player
git push -u origin branch-player

可简化

1
2
git checkout -b branch-player
git push -u origin branch-player

这样创建的新分支是基于当前分支的,即已有commit是当前分支的commit

怎么撤销已有commit

1
2
3
git reset --hard 1e9c6b5fde1cf7512fd6d04ab025a8844dab0e70

git push --force

回退到commit前的版本然后强制推送

之前clone原仓库了,改了代码,要怎么提交pr

1
2
3
4
5
6
7
8
9
    fork

    git remote -v

    git remote set-url origin https://github.com/xxfttkx/maa-copilot-frontend.git

    git remote -v

    push
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计