DEV Community

Discussion on: Which git commands do you struggle with?

 
isaacdlyman profile image
Isaac Lyman

So is it the equivalent of making a fresh branch off of the other branch, then cherry-picking all your commits back onto it? E.g.:

git checkout working-branch
git commit -m "My commit"
git rebase main
Enter fullscreen mode Exit fullscreen mode

==

git checkout working-branch
git commit -m "My commit"
git checkout main
git checkout -b new-working-branch
git cherry-pick {commit hash of "My commit"}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
csgeek profile image
csgeek

Sure, but if you have 15 commits on your branch you'd have to cherry-pick all 15s. rebase is much easier to use, but it is equivalent if you want to use that.

It has other features (squash, reorder, etc) which are really handy that I mentioned earlier though for the standard behavior that is equivalent.