git
2025年6月17日大约 1 分钟
| command | comment |
|---|---|
| git ls-remote --tags | show remote tags |
| git log git reset --hard | clear all update |
| git log --all --oneline --graph --decorate | 显示所有提交 |
| git restore --source=commit id -- 文件名 | 合并指定文件 |
git stash
合并更改
git checkout master
git cherry-pick commit-id
创建新分支
git switch -c 新分支名 master移除已经跟踪的文件
git rm --cached package-lock.json
.gitignore 中添加 package-lock.json彻底清除git所有历史提交记录使其为“新”库
git checkout --orphan latest_branch
git add -A
git commit -m 'init'
git branch -D main
git branch -m main
git push -f origin main另一个分支的所有代码变动
git merge
只需要部分代码变动(某几个提交)
git cherry-pick
查看远程分支
git branch -r
创建并切换分支
这个命令是将git branch newbranch和git checkout newbranch合在一起的结果。
git checkout -b localbranchName remoteBranchname
刷新远程分支
git remote update
忽略已经push的文件
git rm -r --cached /target/
git commit -m '忽略文件'
clone 非22 端口
git clone ssh://git@gitee.com:22/wjn0918/linkis.git
github action
ssh 远程执行
remote-deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: SSH into Server and Deploy
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
docker pull registry.cn-hangzhou.aliyuncs.com/wjn0918/soft:easybd-frontend
docker pull registry.cn-hangzhou.aliyuncs.com/wjn0918/soft:easybd-backend
docker compose -f /opt/easybd/compose.yml down
docker compose -f /opt/easybd/compose.yml up -dSERVER_SSH_KEY 使用~/.ssh/id_rsa
