工作中常用的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

相关推荐
云南新人和数采集团3 小时前
云南靠谱软件开发公司选型指南:以昆明新腾科技为例
大数据·人工智能·科技
AllData公司负责人4 小时前
AI大模型数据开发底座系列说明书:AllData集成DB-GPT开源项目建设 AI 多模态分析底座,涵盖模态解析/智能大屏/MCP 扩展!
大数据·数据库·人工智能·gpt·数据采集·数据接入·模态解析
Elasticsearch7 小时前
过犹不及:为什么搜索结果重排序时,20 个候选结果胜过 200 个
elasticsearch
wno7047 小时前
常用的Git命令清单
大数据·git·elasticsearch
真上帝的左手19 小时前
3. 代码管理-Git-进阶
git·源代码管理
YIN_尹1 天前
【git原理与使用】git基本操作及底层原理(二)
大数据·git·elasticsearch
武子康1 天前
H3-World 写了 CPU offload,为什么还不能保证塞进 48GB?
大数据·人工智能·深度学习
演艺大赏1 天前
Doris 数据导出实战:SeaTunnel、EXPORT 与 OUTFILE 性能对比及 9.5 亿行写入故障复盘
大数据
isfox1 天前
MapReduce 作业慢?别乱调参数,先找到瓶颈在哪
大数据
玩美数据1 天前
市场调研数据分析与数据集驱动的行业格局变革深度解析
大数据·人工智能