DEV Community

Discussion on: Git yourself some cool new tricks

Collapse
 
jerryasher profile image
Jerry Asher • Edited

Interesting article, thanks, though I believe this is not quite right:

Let's see how we can move a commit. There are a couple of ways of doing it, like most things in Git.

Let's imagine that we are in the 'feature/about' branch and we found something to fix in the contact section and committed it there.

We'll now want to move that commit to a different branch like 'feature/contact'. For that let's run the command

git checkout feature/contact

Now we're in the contact branch and if we inspect the log, we'll see that the commit is now in both branches and what's left is to remove it from the first branch

I think this is true iff:

  • feature/contact is a brand new branch you want to split from the current state of feature/about
  • the command you use is git checkout -b feature/contact

But I don't think it would be true if feature/contact is an existing branch split off earlier, is that right?


I've mostly ignored cherry picking, so I greatly appreciate your simple, clear explanation, I'll be looking forward to part 2.

Collapse
 
juanfrank77 profile image
Juan F Gonzalez

Hey Jerry,

Thanks for the comment. You are right, that example would only work if the 'feature/contact' branch was created off of the one we're currently in and not if it already existed.
I think that it's not obvious reading that part again, so appreciate the clarification.

I'm making a small project to use as an example for the followup of this article so it took me longer than expected to writing it 😅