Git is equivalent to hg mq?

I just started using Git with Mercurial to get to know Git.

I am using the mq extension in Mercurial to manage local patches, and I am looking for a Git equivalent.

Should I use the Git branch? Or are there better ways to manage local patches that make patches easy to apply and remove?

Thank,

+49
git mercurial mercurial-queue
Jun 04 '09 at 19:34
source share
4 answers

Check out the Patch Management Interface Interfaces section of Interfaces, Frontend And Tools on the Git Wiki. Two patch management interfaces are listed here, which is roughly equivalent to the mq 'Mercurials extension:

  • StGIT (Stacked Git), the oldest of the two, written in Python, uses two snapshots to represent the patch
  • Guilt (formerly "gq"), written as a series of bash scripts, a series file and patches (one per file) are saved as a text file.
  • pg (Patchy Git) is deprecated and is no longer supported.

But if you don’t need more advanced use, you can use git rebase --interactive "instead to reorder, squash and split patches. And to control the branch from the current version of the upstream," git rebase "will usually be enough.

+28
Jun 04 '09 at 20:18
source share

Disclaimer: I am not a hg user, so I read about hg, but I don't have much experience using it.

git provides some very powerful and flexible branch management tools in a “patch queue” style, so for many basic (and even some fairly complex) cases of using native git, it’s quite powerful.

As a rule, most projects maintain a central stable leading branch, which only receives new commits and never "rewinds", so the commits in the main branch are fixed.

In addition, the maintainer (or developer) can maintain one or more branches of the liquid of incomplete corrections (i.e., commits) that are based on a stable branch.

Typical patch management activities include:

restore the patch queue on the last stable branch - use git rebase ,

duplication of the fix queue on the old maintentance branch - use git branch and git rebase ,

reordering fixes in the queue - use git rebase --interactive (aka git rebase -i ) with a text editor to reorder the queues.

crush patches - use git rebase -i with squash directive

change patches or fix fix messages - use git rebase -i (specify a subject?) with an edit directive.

Any activity that modifies the patch in any way (i.e. its contents, description or parent) will create a new commit with a new commit identifier for that patch. The fact that old commits can be thrown away and replaced regularly before they are transferred to a stable leading branch is the only thing that makes them a “fix queue” and not a branch, but this is a project agreement and not any physical difference in the data that makes up the commits. For git, they are identical objects.

To push a patch to a “real” commit, simply move the patch to the queue and transfer it to the main branch. After moving the patch to the front of the queue, it will be exactly the same as a regular commit based on the main branch, so a simple merge is the main branch pointer forward to indicate the fixation of the patch.

Publishing this commit as a “stable” main patch is an action that states: now it is a commit that will not change and become part of the unchanging history of the project.

+31
Jun 04 '09 at 20:33
source share

Just use a branch and regularly update it in relation to your branch up. This is simpler and safer than using mq (to which I lost data in the past).

+9
Jun 04 '09 at 20:18
source share

Git does not really provide this feature. Depending on your goals, you can go through with "git stash" and / or branches, but it will be quite simple. If people have more complex patch management needs with git, they seem to turn to Quilt or StGit: see http://git.or.cz/gitwiki/PatchManagement

+7
Jun 04 '09 at 20:05
source share



All Articles