git flow

参考
常用git操作

常用git命令

git clone --depth 1  --branch aliyun_openai_dev_iam git@code.alipay.com:data_release/ai-studio.git

# 允许合并
git pull origin master --allow-unrelated-histories

## 查找大文件
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"


git filter-branch -f --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch app/common/service/fg/src/main/resources/linux-x86-64/_external.tar.gz' --tag-name-filter cat -- --all

git remote set-url origin git@code.alipay.com:antcloud-openai/aistudio.git

git push origin aliyun_openai_dev:master


# 可以对某一段线性提交历史进行编辑、删除、复制、粘贴;因此,合理使用rebase命令可以使我们的提交历史干净、简洁!
# start point 不包含 startpoint

git rebase -i  [startpoint]  [endpoint]   


git reset

git reset --soft  可以保留更改到本地workspace ,然后重新commit,可以将多个commit合并成一个,然后提交到远端。

# 重置本地分支为某分支,并推送到远端
git reset --hard origin/xxx
git push -f

git reflog

git reflog后查看hash值
git reset $hash 可以切换到指定的步骤

git 创建空分支

git checkout --orphan emptybranch
git rm -rf . //注意:最后的‘.’不能少。
echo '# new branch' >> README.md

git add README.md

git commit -m 'new branch'
git push origin emptybranch

git 同步另外一个远程仓库的分支

#!/bin/bash
# 用法:./script.sh <其他远程地址> <源分支> <目标分支>
other_repo=$1
source_branch=$2
target_branch=$3

git remote add other-remote $other_repo
git fetch other-remote
git checkout -b $target_branch
git reset --hard other-remote/$source_branch
git push origin $target_branch
git remote remove other-remote

git 忽略远端主机证书异常

ssh-keyscan gitlab.alipay-inc.com >> ~/.ssh/known_hosts
ssh -T git@gitlab.alipay-inc.com