search

Home  >  Q&A  >  body text

Git gets a certain commit of a certain branch?

In my case, I currently maintain a front-end project and use Gitlab's Webhooks for continuous integration. The pushed code is automatically distributed to the CDN with a version number.

The situation is as follows:

I need to fix two problems locally. I fixed them locally and submitted them to the same version twice (not pushed yet). However, these two problems need to be released twice (because the business parties are different), so I These two commits must be separated into two branches.

So my question is:

How to get a certain commit from branch B and put it into branch A?

My own approach is like this:

git checkout branch-B
git reset --soft HEAD^
git checkout branch-A
git commit -m -a 'your comment'

However: It feels very uncomfortable to do this and does not have that smooth experience; and you cannot specify to get a certain submission at will.

PHP中文网PHP中文网2813 days ago636

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-02 09:32:28

    I suggest you take a look cherry-pick 这个命令,可以把任意 commit to merge, but be careful: use with caution, use with caution, use with caution!

    reply
    0
  • Cancelreply