Mercurial copy patch to repository

I’m using Mercurial repository and I have a patch in ‘git‘ format and I wanted to know how I can apply that patch to my current repository which is Local.

Thanks

  • Keeping track of external git repos merged through `git subtree`
  • Having trouble committing to git with Visual Studio
  • Compare old and new versions of force-pushed pull request
  • How to find the date of the first commit of files in git
  • Elastic Beanstalk, Git and AWS Tools: How to clone repository to another workstation
  • How to remove a too large file in a commit when my branch is ahead of master by 5 commits
  • Merge an untracked directory into the tracked directory
  • Unpacker error Git-pushing from bare repo to staging server
  • Git pull --rebase converting spaces to tabs
  • Git: What do the numbers reported by `git fetch` mean?
  • How do I use git worktrees in IntelliJ IDEA 2016.1?
  • Cleaning my git branch of features in development
  • 2 Solutions collect form web for “Mercurial copy patch to repository”

    hg import <patchfile(s)> should be able to handle git-style patches.

    Use hg import --no-commit <patchfile(s)> if you don’t want it to automatically commit the changes after each patch is imported.

    Mozilla’s FAQ mentions this: https://developer.mozilla.org/en/Mercurial_FAQ#How_can_I_diff_and_patch_files.3f

    Try hg import --no-commit, Mozilla has a rather useful FAQ regarding trading patches between Git and Mercurial.

    Depending on your platform, you can also just use patch, e.g. patch -p1 < some_patch_from_git.patch. That may actually be better as you’ll see any fuzz and not have to deal with trusting the author just for one patch.

    Edit

    If your patch does not go in cleanly, none of the above methods are going to work. Your code base is not what the patch expects if hunks fail to apply. Look at the rejects and see what the patch expected your code to be at any given line, then rebase accordingly.

    Git Baby is a git and github fan, let's start git clone.