git快进一次提交 [英] git fast-forward one commit

查看:85
本文介绍了git快进一次提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

* 9dbd857 (hotfix-correct-java-jdk-path, feature/add-ansible-galaxy-requirements-file) requirements.yml: adds maven and nodejs requirements
* 1643619 (QOL-1640-enable-vpc-peering) roles/ansible-linux-commons: change value of hostname in cloud-init
* b5fd2a4 roles/bamboo-agent: add bitbucket ssh host key to /etc/ssh/ssh_known_hosts
* d5cc1f7 vpc cfn template: produce outputs conditionally
* 3b87efe vpc cfn template: use csv for subnet/AZ mapping
* 2e93096 roles/bamboo-agent: Install chrome on agents
* 9aeb07e roles/bamboo-agent: install chromium browser
* 89e852d (HEAD -> feature/QOL-1649-install-chrome) README: display the current directory structure of inventories
* 1f55c4b inventories/test: define root volume size
* 07d902e bamboo-ec2 cfn: specify root volume size

这是我(最近)的历史.

This is my (recent) history.

我希望 feature/QOL-1649-install-chrome 上移一次提交,移至 9aeb07e .

I want feature/QOL-1649-install-chrome to move up one commit, to 9aeb07e.

我尝试了樱桃挑选",但是后来我得到了该提交的副本"到 feature/QOL-1649-install-chrome 分支上.但是我想(我认为)是个快进.

I tried cherry pick, but then I get a "copy" of that commit onto the feature/QOL-1649-install-chrome branch. But what I want (i think) is a fast-forward.

推荐答案

您可以对其进行 git reset ,但是出于一般安全和清洁的考虑,我更喜欢使用 git merge --ff-仅.要使用它,请签出您要快速转发的分支(您已经拥有),然后运行 git merge --ff-only< commit-hash> :

You can git reset to it, but for general safety and cleanness, I prefer to use git merge --ff-only. To use it, check out the branch you want fast-forwarded (you have already), then run git merge --ff-only <commit-hash>:

git merge --ff-only 9aeb07e

我经常使用此命令,因此我为其命名为 git mff (合并快进).

I use this command so often that I made an alias for it, git mff (merge fast forward).

编辑,2020年11月:请注意,您不必在此处使用原始哈希ID; git mff origin/somebranch 也可以正常工作.您可以在此处使用原始哈希.这是Git中一条通用规则的一部分:如果可以使用原始哈希,则可以使用分支名称,标签名称,远程跟踪名称等等.

Edit, Nov 2020: note that you do not have to use a raw hash ID here; git mff origin/somebranch works fine too. You can use a raw hash here. This is part of a general rule in Git: if you can use a raw hash, you can use a branch name, a tag name, a remote-tracking name, and so on.

此通用规则有一些特殊情况,特别是,如果您在 git checkout 命令中使用原始哈希ID,您将得到Git称为分离式HEAD的信息,而如果您在 git checkout 中使用分支名称,则您将在分支上".(即,一个 attached HEAD:与detached相反,尽管Git文档从来没有这样称呼它:它只是说在分支上").在Git 2.23和更高版本中,新的 git switch 命令在此方面更好,因为如果要切换到分离头模式,它要求您添加-detach 选项.但是,有了这个 git mff 别名,就没有什么特别的需要担心了.

There are a few special cases around this general rule, and in particular, if you use a raw hash ID with the git checkout command, you will get what Git calls a detached HEAD, while if you use a branch name with git checkout, you will be "on the branch" (i.e., an attached HEAD: the opposite of detached, although Git documentation never calls it this: it just says "on a branch"). The new git switch command, in Git 2.23 and later, is better about this in that if it's going to switch to detached-HEAD mode, it demands that you add the --detach option. With this git mff alias, however, there's no special case to worry about.

这篇关于git快进一次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆