git删除之前所有的commit信息

  1. 拉取代码 git clone -b master url
  2. git checkout --orphan orphan 创建一个无父节点的branch
  3. git merge 合并主分支的 目前在孤儿分支上
  4. 接着 git add . git commit -m “xxx”
  5. git switch master
  6. git reset --hard orphan 将master reset到跟new一样的位置
  7. git push --force-with-lease origin main
git  branch -a
查看所有分支
git switch master
git pull
-d Delete a branch. The branch must be fully merged in its upstream branch
-D force delete
git checkout --orphan orphan
现在已经切换到了这个孤儿分支上了
git add .
git commit -m "origin commit"
git switch master
git reset --hard orphan
git push --force-with-lease origin master

你可能感兴趣的:(git,github)