Conflicts in Git Rebasing

After using Git for a while I’m finding the most confusing aspect of it is rebasing. The git-rebase man page says “forward-port local commits to the updated upstream head”. Hmm. Thankfully James Bowes posted a solid explanation of the basic principles.

Which leaves me wondering about corner cases. I have local commits which I’ve submitted as patches upstream. Now I’ll be fetching my changes from upstream, one of which has an updated comment and the other has had minor edits applied. How does Git handle this? In a good way! For commits which are already upstream, with identical content, even with differing comments, rebasing removes the local commit. That’s exactly what you want. For example simply specify the upstream branch to rebase against:

git rebase origin/master

In cases where the commit contents have received minor edits the rebase will pause. Assuming you are happy to drop the local commit tell Git to do exactly that:

git rebase --skip

or if there’s any doubt tell Git to rollback to before the rebase started:

git rebase --abort
Advertisement

Navigating Source Code

Recently I’ve been browsing free software projects on Linux, and wanting to navigate a mixture of C and C++. I’m used to Visual Studio on Windows, more accurately the excellent Visual Assist plug-in, which makes code navigation and completion work for C++. For me this is the best feature of the whole setup: Visual Studio is a way to run Visual Assist. I’ve really missed this on Linux.

Years ago I used a combination tag files generated during the build and some custom Crisp macros for source code navigation. Despite not providing auto-completion this was in some ways better than Visual Assist as tags are generated from pre-processed source:

  • C macros and condition includes do not break the tagging
  • Tag files are per-platform, per build-type and exact

Still, what I wanted was something quick to setup and use with Emacs. A while back Pete Ivey recommended GNU Global, so I thought I’d try that out. Overall it works really well. It’s not without it’s flaws – some variable declarations are hidden in macros in the code I’m reading. Those get missed from the declaration list, but do get caught as symbols. Ideally I’d expand the Emacs macros to automatically search for any symbol if a declaration isn’t found.

The pendant in me want to set up Dehydra and hook it into the build system. The pragmatist says that overall this is working well. For now I’m sticking with it.

What are other people using?