git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Need help migrating workflow from svn to git.

From
IDIgor Djordjevic <igor.d.djordjevic@gmail.com>
Date
Dec 21, 2017, 22:04 UTC
Message-ID
<fdf75150-eca0-dde5-a305-ae5fd5c35369@gmail.com>
In-Reply-To
<20171220114337.GE18542@raven.inka.de>
Hi Josef,
On 20/12/2017 12:43, Josef Wolf wrote:
Show 6 quoted lines
> 
>>     $ git add -u
>>     $ git reset
> 
> This would be added after the "git checkout -m -B master FETCH_HEAD" 
> command?
Yes, so it would be something like this:
    git fetch origin master &&              #1
    git checkout -m -B master FETCH_HEAD && #2
    git add -u &&                           #3
    git reset                               #4

But it actually depends on what kind of default `git diff` output you prefer.

In order to avoid failure on subsequent script runs, in case where conflicts still exist, you need to ensure #3 and #4 are executed before #1 and #2 are executed _again_.

So you may put #3 and #4 in front of #1 and #2, too, that would work just as well, where `git diff` would now be showing "combined diff"[2] as long as the script isn`t executed again (and it would keep showing new "combined diff" from that point on).

Show 6 quoted lines
>> Yes, `git diff` won`t be the same as if conflicts were still in, but 
>> it might be worth it in this specific case, conflicting parts still 
>> easily visible between conflict markers.
> 
> That means, the conflict is still there, but git would think this is 
> an ordinary modification?

Yes, as by that `git add -u` you confirm all merge conflicts are resolved, and `git diff` output changes accordingly. You can read more about "diff format for merges"[1] and "combined diff format"[2] from `git-diff`[3] documentation.

Here are some examples from my test repositories. Local repo introduces line "A1" (local modification, uncommitted), where remote repo introduced line "B1" (commit). Steps #1 and #2 get executed, merge conflicts shown with `git diff`, before `git add -u` and `git reset`:

    $ git diff
    diff --cc A
    index 5314b4f,1e2b966..0000000
    --- a/A
    +++ b/A
    @@@ -12,5 -12,5 +12,9 @@@
      2
      3
      4
    ++<<<<<<< FETCH_HEAD
     +B1
    ++=======
    + A1
    ++>>>>>>> local
      5

... and after `git add -u` and `git reset` (note line "B1" not showing as changed anymore):

    $ git diff
    diff --git a/A b/A
    index 5314b4f..8ea9600 100644
    --- a/A
    +++ b/A
    @@ -12,5 +12,9 @@ A
     2
     3
     4
    +<<<<<<< FETCH_HEAD
     B1
    +=======
    +A1
    +>>>>>>> local
     5

Now, without any commits yet made locally (except commit pulled from remote repo), local repo adds line "A2" where remote repo introduces line "B2" (commit). Steps #1 and #2 get executed again, merge conflicts shown with `git diff`, before `git add -u` and `git reset`:

    $ git diff
    diff --cc A
    index 424ae9e,4aac880..0000000
    --- a/A
    +++ b/A
    @@@ -2,7 -2,7 +2,11 @@@
      1
      2
      3
    ++<<<<<<< FETCH_HEAD
     +B2
    ++=======
    + A2
    ++>>>>>>> local
      4
      5
      6

... and after `git add -u` and `git reset` (note showing line "B2" as unchanged, and now showing leftover "conflicts" around "A1" here as well, where previous "combined" diff discarded it as uninteresting due to implied "--cc"[4] flag):

    $ git diff
    diff --git a/A b/A
    index 424ae9e..77ad8e6 100644
    --- a/A
    +++ b/A
    @@ -2,7 +2,11 @@ A
     1
     2
     3
    +<<<<<<< FETCH_HEAD
     B2
    +=======
    +A2
    +>>>>>>> local
     4
     5
     6
    @@ -13,5 +17,9 @@ A3
     2
     3
     4
    +<<<<<<< FETCH_HEAD
     B1
    +=======
    +A1
    +>>>>>>> local
     5
Hope that helps. As usual, best to give it some try on your own :)
Regards, Buga

[1] https://git-scm.com/docs/git-diff#_diff_format_for_merges [2] https://git-scm.com/docs/git-diff#_combined_diff_format [3] https://git-scm.com/docs/git-diff [4] https://git-scm.com/docs/git-diff-tree#git-diff-tree---cc

Previous: Josef Wolf
Message 16 of 16 in “Need help migrating workflow from svn to git.”
  1. Josef WolfDec 14, 2017
  2. Randall S. BeckerDec 14, 2017
  3. Josef WolfDec 15, 2017
  4. Igor DjordjevicDec 14, 2017
  5. Igor DjordjevicDec 15, 2017
  6. Josef WolfDec 15, 2017
  7. Josef WolfDec 15, 2017
  8. Igor DjordjevicDec 15, 2017
  9. Junio C HamanoDec 15, 2017
  10. Igor DjordjevicDec 15, 2017
  11. Junio C HamanoDec 15, 2017
  12. Igor DjordjevicDec 15, 2017
  13. Josef WolfDec 20, 2017
  14. Josef WolfDec 20, 2017
  15. Josef WolfDec 20, 2017
  16. Igor DjordjevicDec 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.