Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As <a href="https://stackoverflow.com/a/4273436/624066">iCrazy</a> said, this feature is only available for git 1.7.3 onwards. So, for the poor souls (like me) still using 1.7.1, I present a solution I did myself:</p> <p><a href="https://github.com/MestreLion/git-tools/blob/master/git-rebase-theirs" rel="nofollow noreferrer">git-rebase-theirs</a></p> <p>It is a very well-polished (and thus long) script, meant for production use: ui options, handles multiple files, check if file actually has conflict markers, etc, but the "core" could be summarized in 2 lines:</p> <pre class="lang-sh prettyprint-override"><code>cp file file.bak awk '/^&lt;+ HEAD$/,/^=+$/{next} /^&gt;+ /{next} 1' file.bak &gt; file </code></pre> <p>And here is the full script:</p> <pre class="lang-sh prettyprint-override"><code>#!/bin/bash # # git-rebase-theirs - Resolve rebase conflicts by favoring 'theirs' version # # Copyright (C) 2012 Rodrigo Silva (MestreLion) &lt;linux@rodrigosilva.com&gt; # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not see &lt;http://www.gnu.org/licenses/gpl.html&gt; #Defaults: verbose=0 backup=1 inplace=0 ext=".bak" message() { printf "%s\n" "$1" &gt;&amp;2 ; } skip() { message "skipping ${2:-$file}${1:+: $1}"; continue ; } argerr() { printf "%s: %s\n" "$myname" "${1:-error}" &gt;&amp;2 ; usage 1 ; } invalid() { argerr "invalid option: $1" ; } missing() { argerr "missing${1:+ $1} operand." ; } usage() { cat &lt;&lt;- USAGE Usage: $myname [options] [--] FILE... USAGE if [[ "$1" ]] ; then cat &gt;&amp;2 &lt;&lt;- USAGE Try '$myname --help' for more information. USAGE exit 1 fi cat &lt;&lt;-USAGE Resolve git rebase conflicts in FILE(s) by favoring 'theirs' version When using git rebase, conflicts are usually wanted to be resolved by favoring the &lt;working branch&gt; version (the branch being rebased, 'theirs' side in a rebase), instead of the &lt;upstream&gt; version (the base branch, 'ours' side) But git rebase --strategy -X theirs is only available from git 1.7.3 For older versions, $myname is the solution. It works by discarding all lines between '&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD' and '========' inclusive, and also the the '&gt;&gt;&gt;&gt;&gt;&gt; commit' marker. By default it outputs to stdout, but files can be edited in-place using --in-place, which, unlike sed, creates a backup by default. Options: -h|--help show this page. -v|--verbose print more details in stderr. --in-place[=SUFFIX] edit files in place, creating a backup with SUFFIX extension. Default if blank is ""$ext" --no-backup disables backup Copyright (C) 2012 Rodrigo Silva (MestreLion) &lt;linux@rodrigosilva.com&gt; License: GPLv3 or later. See &lt;http://www.gnu.org/licenses/gpl.html&gt; USAGE exit 0 } myname="${0##*/}" # Option handling files=() while (( $# )); do case "$1" in -h|--help ) usage ;; -v|--verbose ) verbose=1 ;; --no-backup ) backup=0 ;; --in-place ) inplace=1 ;; --in-place=* ) inplace=1 suffix="${1#*=}" ;; -* ) invalid "$1" ;; -- ) shift ; break ;; * ) files+=( "$1" ) ;; esac shift done files+=( "$@" ) (( "${#files[@]}" )) || missing "FILE" ext=${suffix:-$ext} for file in "${files[@]}"; do [[ -f "$file" ]] || skip "not a valid file" if ((inplace)); then outfile=$(tempfile) || skip "could not create temporary file" trap 'rm -f -- "$outfile"' EXIT cp "$file" "$outfile" || skip exec 3&gt;"$outfile" else exec 3&gt;&amp;1 fi # Do the magic :) awk '/^&lt;+ HEAD$/,/^=+$/{next} /^&gt;+ /{next} 1' "$file" &gt;&amp;3 exec 3&gt;&amp;- ((inplace)) || continue diff "$file" "$outfile" &gt;/dev/null &amp;&amp; skip "no conflict markers found" ((backup)) &amp;&amp; { cp "$file" "$file$ext" || skip "could not backup" ; } cp "$outfile" "$file" || skip "could not edit in-place" ((verbose)) &amp;&amp; message "resolved ${file}" done </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload