个人小程序怎么赚钱,上海网站排名优化,电商导购网站开发,网站建设兼职合同背景
有时git提交了太多有些较早之前的提交日志#xff0c;不想在git log看到#xff0c;想把他删除掉。
方法
大概思路是通过 git clone --depth 来克隆到指定提交的代码#xff0c;此时再早之前的日志是没有的
然后提交到新仓库
#!/bin/bash
ori_gitgityour.gi…背景
有时git提交了太多有些较早之前的提交日志不想在git log看到想把他删除掉。
方法
大概思路是通过 git clone --depth 来克隆到指定提交的代码此时再早之前的日志是没有的
然后提交到新仓库
#!/bin/bash
ori_gitgityour.git.path/ori-prj.git #源仓库
ori_branchmaster
ori_pathori-prjdest_gitgityour.git.path/dest-prj.git #需要提交到变更后的仓库
dest_branchmaster
dest_pathdest-prj
previous_commit41059bbcc349de4faccf484326a94d3c816cdd05 #从哪个id开始拉不包含当前idif [ -d $ori_path ]; thenecho $ori_path exist
elseecho git clone $ori_git --branch$ori_branch $dest_pathgit clone $ori_git --branch$ori_branch $ori_path
ficd $ori_path
git pull
#判断分支是否存在 没有的话拉一下
if test -z $(git branch |grep $ori_branch); thengit checkout remotes/origin/$ori_branch -b $ori_branch
fi
git checkout $ori_branch# 获取id对应的深度
current_commit$(git rev-parse HEAD)
commit_count$(git log --oneline $previous_commit..$current_commit | wc -l)echo $commit_countcd ..
#只克隆到指定id的提交记录
rm -rf $dest_path
git clone $ori_git --depth$commit_count --branch$ori_branch $dest_path
cd $dest_path
git filter-branch -- --all # 要执行下这命令不然推不上去
git remote rename origin old-origin
git remote add origin $dest_git
git push origin $ori_branch:$dest_branch --force
echo $ori_branch:$dest_branch
cd ..