工作中常用的git命令,千万不能忘

1、设置当前分支为默认分支:

git branch --set-upstream-to=origin/master

2、To push the current branch and set the remote as upstream, use:

git push --set-upstream origin eds_enhancement

3、同步远程分支

git remote update --prune [remote]

4、Remove a file from a Git repository without deleting it from the local filesystem

For single file:

git rm --cached mylogfile.log

For single directory:

git rm --cached -r mydirectory

5 undo git add . from staged

git reset

git reset <file path>

or undo all staged files:

git reset HEAD .

6 commit to gateWay

git push origin HEAD:refs/for/19.1.1_sparkle

7 撤销提交

git revert [commit id]

8 查看文件变动

git show --name-only {commit}

9 squash commits to one(将多个commits压成一个)

git rebase -i [commit-id (not contained it)]

note:

select by `s` short command

10 在最近的commit上追加文件变动

git add the_left_out_file

git commit --amend --no-edit

or

git reset HEAD^

git add again

11 撤回部分file的commit

step 1: git reset --soft HEAD^1

step 2: git reset <file path>

git rm --cached <file-name>(如果要刪除此文件)

12 恢复reset

git reflog

13 list all conflict files

git diff --name-only --diff-filter=U

14 add message to stash command

git stash save <messages>

15 rebase local branch with remote master

step1: git fetch origin # Updates origin/master

step2: git rebase origin/master # Rebases current branch onto origin/master

16 change commit message to latest commit

git commit --amend -m "New commit message."

17 git log --author=<author name>

18 git alias

git config --global alias.p 'push'

git p

相关推荐
白鲸开源几秒前
实战干货:Apache DolphinScheduler 参数使用与优化总结
大数据·程序员·开源
秦jh_6 分钟前
【git】远程操作
git
yumgpkpm20 分钟前
CMP(类Cloudera CDP 7.3 404版华为Kunpeng)与其他大数据平台对比
大数据·hive·hadoop·elasticsearch·kafka·hbase·cloudera
JZC_xiaozhong1 小时前
跨系统流程如何打通?选 BPM 平台认准这三点
大数据·运维·自动化·数据集成与应用集成·业务流程管理·流程设计可视化·流程监控
中科岩创1 小时前
某地公园桥梁自动化监测服务项目
大数据·人工智能·物联网·自动化
希赛网1 小时前
2025年第四期DAMA数据治理CDGA考试练习题
大数据·cdga·cdgp·dama·数据治理·题库
keep__go3 小时前
zookeeper单机版安装
大数据·运维·zookeeper
Serverless 社区4 小时前
助力企业构建 AI 原生应用,函数计算FunctionAI 重塑模型服务与 Agent 全栈生态
大数据·人工智能
武子康4 小时前
大数据-150 Apache Druid 单机部署实战:架构速览、启动清单与故障速修
大数据·后端·apache
ApacheSeaTunnel5 小时前
结项报告完整版 | Apache SeaTunnel支持metalake开发
大数据·开源·数据集成·seatunnel·数据同步