Reputation: 135
whenever i start developing any new feature i checkout to new branch and rebased that branch with develop branch. in my case develop is the base branch. if the develop branch is updated while i am working on feature branch i simply checkout to develop branch and take the pull of that branch and then checkout to my feature branch and rebased it with develop branch again.
i want to know what would happen if i do git merge instead of git rebase in this process.
git workflow:
git checkout develop
git pull origin develop
git checkout -b CM-255/feature
git rebase develop #what will happen if i use git merge here instead of git rebase
git commit -m "example"
git push origin CM-255/feature
create pull request for CM-255/feature
pull request merged into master branch
Upvotes: 0
Views: 1395
Reputation: 373
The main benefit of rebase is that it starts a much "cleaner" approach.
First, it eliminates unnecessary merge, which is required by git merge
.
Secondly, rebasing also results in a perfectly linear project history where you can track the start of the entire project path,
without any problems. This makes it easier to navigate your project with commands like git log, git bisect and gitk
.
But there are two compromise solutions to this story:
rebasing
loses the context provided by a merge commit
, if you can not see when
the upstream changes have been incorporated into the resource.The best way to understand the whole process is to read the following article:
Also I leave here images that summarize a good example of application:
Upvotes: 4
Reputation: 43700
In your workflow the big difference would be when there is a new commit on develop
. In which case if you use merge
instead of rebase
, you will get a commit stating merging branch develop
. This is from git combining the changes from your local branch with what is on develop
.
When you rebase, git takes your local commits and sets them aside. Then it brings the changes from develop and adds them to your branch. After this is done, it re-applies your commits one at a time.
I prefer rebase because it keeps the history clean on my branch. In general, there is no functional difference between the two. As any conflicts that happen will either be resolved when you merge or when the commit is applied.
Upvotes: 0