Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+14 votes

Good evening guys, I am having trouble with the command "git rebase" although I have been messing around with it on the https://learngitbranching.js.org website for an hour now. Does it copy a commit from one branch to another? If it does, then what is the difference between "git rebase" and "git cherry-pick". Can someone please explain this to me?

asked in CSC 305 Fall 2024 by (1.1k points)

2 Answers

+7 votes

git rebase replays a series of commits from one branch onto another, effectively aligning the branch with a new base while rewriting commit history to make it linear. For example, git rebase main on a feature branch moves the feature onto main and reapplies its commits on top of the latest changes in main. In contrast, git cherry-pick applies specific commits (identified by their hash) from one branch to another without altering history. While rebase is used for integrating and aligning branches, cherry-pick is ideal for selectively copying individual commits.

answered by (4.4k points)
+3

Thank you so much Zekarias

0 votes

git rebase moves or replays your branch's commits onto another branch's tip, creating a linear history. It's useful for keeping a clean project history and integrating changes without a merge commit.

answered by (2.1k points)
...