欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > Git 常见操作

Git 常见操作

2025/6/12 23:51:53 来源:https://blog.csdn.net/qq_40178082/article/details/148513066  浏览:    关键词:Git 常见操作

目录

1.git stash

2.合并多个commit

3. git commit -amend (后悔药)

4.版本回退

5.merge和rebase

6.cherry pick

7.分支

8.alias


1.git stash

git-stash操作_git stash 怎么增加更改内容-CSDN博客

2.合并多个commit

通过git bash工具交互式操作。

1.查询commit的commitID

git log --oneline

--oneline参数,代表将每个commit压缩成一行,只显示commitID和commit message的第一行。

d5ace53 第5次commit
25d5ae5 第4次commit
73c98f9 第3次commit
a50f132 第2次commit
d5d1335 第1次commit

2.变基到第一次commit,开启交互式操作。

git rebase -i d5d1335

 -i 参数,代表展开交互界面

pick a50f132 第2次commit
pick 73c98f9 第3次commit
pick 25d5ae5 第4次commit
pick d5ace53 第5次commit# Rebase d5d1335..d5ace53 onto d5d1335 (4 command)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
#                    commit's log message, unless -C is used, in which case
#                    keep only this commit's message; -c is same as -C but
#                    opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later wit

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词