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

相关推荐
Q26433650232 小时前
【有源码】基于 Hadoop 生态的化妆品销售数据存储分析与可视化 面向化妆品行业的用户画像构建与销售机会识别研究
大数据·hadoop·python·机器学习·spark·毕业设计·课程设计
2601_962218618 小时前
万象生鲜系统业财一体化底层打通技术自动生成经营账单
大数据·数据库·人工智能·python·算法
Easy_API9 小时前
从“有多少卡“到“卖多少 Token“:算力的标尺正在换
大数据·人工智能·深度学习
末央&10 小时前
GIT工具的基础指令与使用
git
移动云开发者联盟10 小时前
中国移动发布全链条算力服务成果
大数据
晓窗科技11 小时前
口碑好的AI基座服务商
大数据·人工智能·python
和裕11 小时前
蜂窝板 vs 七层瓦楞重型纸箱:大件工业设备运输性能与成本全对比
大数据·运维·网络·人工智能·算法
ACP广源盛1392462567311 小时前
国产 PCIe2.1 交换芯片 IX6024:低成本轻量化端侧 AI IO 扩展选型解析
大数据·人工智能·硬件架构·pcie·国产芯片
小王毕业啦11 小时前
2012-2024年 机构投资者实地调研数据 xlsx
大数据·人工智能·数据挖掘·数据分析·社科数据·实证分析·经管数据
制造业的搬运工12 小时前
智能家居工控PCB可靠性检测规范与制程管控实践
大数据·网络·人工智能·制造·pcb工艺