npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-resolve-conflict

v2.0.0

Published

Resolve git conflict in a given file, using given strategy (--ours, --theirs, --union)

Downloads

46

Readme

git-resolve-conflict <strategy> <filename>

Resolve merge conflict in just one file, using given strategy (--ours, --theirs, --union)

git resolve-conflict --ours package.json
git resolve-conflict --theirs package.json
git resolve-conflict --union package.json

git resolve-ours package.json
git resolve-theirs package.json
git resolve-union package.json

Why would you need it

To be able to resolve certain well-defined types of merge conflicts, without opening mergetool.

This is particularly useful in automated merge scripts (for example, Jenkins jobs), or if you have large number of well-defined merges to resolve.

Installation

  • copy /lib/git-resolve-conflict.sh to your .bashrc (this adds just git resolve-conflict)
  • or npm install -g git-resolve-conflict (this also adds 3 other helpers)

Get it on npm

npm installation is the recommended way, so that you can easily get updates in the future.

FAQ

  • Q: Why no updates in 3 years?

  • A: Because it works™. It's feature-complete.

  • Q: Does it work on Windows?

  • A: Yep, but it'a shell script, so you need a unix-y shell. I'm using it with git bash and it works well.

  • Q: Why you distribute through npm?

  • A: Just to make it easier to install if you happen to have node. The script itself is shell.

TL;DR

It's just a tiny wrapper around git-merge-file to simplify the API. See ./lib/git-resolve-conflict.sh. (I used temp files instead of process substitution to make it msys/mingw-friendly).

It's better than git merge -Xours because that would resolve conflicts for all files. Here we can resolve conflict for just one file.

It's better than git checkout --ours package.json because that would lose changes from theirs even if they are not conflicted. Here we can resolve conflict using a three-way merge and keep the non-conflicted changes from both sides.

See also http://stackoverflow.com/q/39126509/245966

Description

Say you have multiple git branches and you want to merge between them, and always resolve conflicts in a particular file with a fixed strategy (say ours).

For instance, you have master (stable) and develop (unstable) branches. When code is stable you freeze the master, and development continues in develop, which is merged to master every few weeks.

But then you find our bugs at regression testing stage, you fix them in master, and you build. In the meantime, you also build develop separately. Each build bumps version field in package.json.

Since those branches can be built separately, a file like package.json will be modified in both branches, and there'll be a merge conflict due to version field being changed in both branches.

How to easily resolve the merge conflict in an automated manner (script) in such a situation?

git built-ins that do not solve the problem

  • git merge -Xours: that would resolve ALL conflicts in ALL files using the same strategy. This might be too much. (For instance, you might want to have an automatic merging script, which can do a successful conflict resolution only if foobar.json is the only file that was modified; on any other files modified, the merge should fail)

  • git checkout --ours filename.txt: that would discard ALL the changes from theirs version, which is brutal. There might be some valid, non-conflicting changes that would be discarded this way.

  • What we need is something like git-resolve-conflict --ours filename.txt

This is what ./lib/git-resolve-conflict.sh from this repo provides.

Details

See README-extended.md