Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to perform a commit after a rebase?

Tags:

git

rebase

I've just rebased a feature branch onto another feature branch (in preparation for rebasing everything to the head of my master), and it involved quite a few tricky merge resolutions.

Is the rebase automatically saved as a commit somewhere?

Just where do those modifications live? I can't see anything in gitk, or git log --oneline.

(Same question for when I merge back my branch after rebasing.)

like image 403
Benjol Avatar asked Apr 22 '10 09:04

Benjol


People also ask

What happens to commits after rebase?

If another user has rebased and force pushed to the branch that you're committing to, a git pull will then overwrite any commits you have based off that previous branch with the tip that was force pushed. Luckily, using git reflog you can get the reflog of the remote branch.

Do I need to commit and push after rebase?

To push the changes to the branch after a rebase, you need to force push your commits using the -f or --force flag in the git push command on Git. This is because something has changed in the remote branch and the commit history is different for both the remote and your local branch.

Do I need to commit before git rebase -- continue?

For each change you make, you'll need to perform a new commit, and you can do that by entering the git commit --amend command. When you're finished making all your changes, you can run git rebase --continue . As before, Git is showing the commit message for you to edit.

Can I rebase before commit?

Before rebasinggit rebase rewrites the commit history. It can be harmful to do it in shared branches. It can cause complex and hard to resolve merge conflicts. In these cases, instead of rebasing your branch against the default branch, consider pulling it instead ( git pull origin master ).


1 Answers

Rebase is moving commits on top of another branch. If a commit that is moved causes merge conflict, this commit is changed to reflect merge resolution.

The purpose of rebase is make your commits look as if they were changes to the branch you rebase onto. So the most logical way is to incorporate merge conflicts into these commits. No additional commits is required thus.

Merge is different, because it's an explicit action of merging diverged branches together. No commits in each of branches is changed. Conflict resolution is reflected in the merge commit.

like image 92
P Shved Avatar answered Oct 05 '22 23:10

P Shved