常用git命令

发布时间 2023-09-14 23:48:13作者: adamaik
  1. git init 初始化仓库
  2. git add . 将所有文件添加到待提交
  3. git cimmit -m "" 提交修改
  4. git log 查看提交记录
  5. git status 查看当前状态
  6. git reset --hard (hash值) 返回hash所代表的提交时的样子,没有最后的参数就默认是上次
  7. git remote add (name) (url) 添加远程仓库
  8. git push github main 推送到GitHub仓库的main分支
  9. git pull github main 拉取main分支并合并,但是不能有提交历史冲突
  10. git branch -m master main 将分支从master切换到main
  11. git fetch github main 拉取GitHubmain分支
  12. git merge --allow-unrelated-histories github/main 允许不同提交历史的github与main分支强行合并