My application requires constant merges from multiple branches per day and multiple releases per day sometimes. I like rebase's ability to help me isolate from the master branch only the code that has changed in my feature branch. However, rebasing often turns into a nightmare when I'm handling 10 or 20 conflicts as the changes are played back. Each of those conflicts has the potential to be resolved wrongly and I'd like to avoid it. Is there a way to do a "quick" rebase where it doesn't actually play back the changes from the rebased-to branch but just uses the latest of that branch, and modifies the feature branch such that it contains only the differences from the latest rebased-to branch? i.e. it doesn't care about history, it just does a diff and uses patch on the latest of each branch to rebase?
Asked
Active
Viewed 826 times
1 Answers
0
What you're looking for is a squash which you can do on a merge with git merge --squash
and rebase is a little more complicated.
However, if you're just reviewing the code and want to see what has changed in a feature branch (not the diff between the branch and master), you can use git log master..branch
to see all the changes in the branch and git diff master...branch
(note the triple dot) to see what was changed in the branch.
git diff [--options] <commit>...<commit> [--] [<path>...] This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B". You can omit any one of <commit>, which has the same effect as using HEAD instead.
See the gitrevisions man page and Revision Selection in Pro Git for more details about the triple dot.
-
That's what I'm doing now, git rebase -i. It's a real headache because it plays back all the changes. I don't want that. Often the same piece of code is edited over and over and during a rebase I have to resolve conflicts over and over again when all I care about is the final version of master and how it compares to my branch. When I --merge it's a one step process. I just have to resolve the conflicts once. I'd like a rebase that is that easy. I didn't know about that diff ... command. That might help a lot. Thanks. – Walt Howard Feb 10 '15 at 15:33