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

Re: Using git to track my PhD thesis, couple of questions

From
Paolo Bonzini <bonzini@gnu.org>
Date
Aug 28, 2009, 15:50 UTC
Message-ID
<4A97FCC4.5070808@gnu.org>
In-Reply-To
<20090828133708.GA11146@kisimul>
On 08/28/2009 03:37 PM, seanh wrote:
Show 5 quoted lines
> In response to Matthieu and Paolo, I'm not sure I understand the git
> internals involved in the discussion around merge --squash, I had a
> feeling this would produce a 'merge' that git in some sense would 'not
> know about', since it sounds complex and I don't understand it I don't
> think I want to go there.

Yes, the problem is that git does not track what happens when you do "git merge --squash", which makes it harder to do merges after some time (because of conflicts).

The solution I gave (and Matthieu explained how it works, even though it's very technical) is a way to "explain" git what you did. If you try it on a fake example with gitk, you should understand it better.

    mkdir test
    cd test
    # import
    git init
    echo a > test
    git add a
    git commit -m1
    # some changes happen in your local "fine grained" branch
    git checkout -b local
    echo b > test
    git commit -a -m2
    echo c >> test
    git commit -a -m3                                  ##<<<
    # the magic incantation brings those commit to master
    # (first two commands) and teaches git what happened (last two)
    git checkout master
    git merge --squash local; git commit -m'merge 1'   ##<<<
    git checkout local
    git merge master                                   ##<<<
    # more local changes
    sed -i s/b/d/ test
    git commit -a -m4
    echo z >> test
    git commit -a -m5                                  ##<<<
    # the magic incantation, again
    git checkout master
    git merge --squash local; git commit -m'merge 1'   ##<<<
    git checkout local
    git merge master                                   ##<<<
Use gitk at the points indicated with ##<<<

It is actually very similar to what you chose to do. My commits to master, in practice, are your tags. You may want to see how gitk's graphs looks in both scenarios, and choose the one that you prefer.

Hope this helps!
Paolo
Previous: david@lang.hmNext: demerphq
Message 18 of 23 in “Using git to track my PhD thesis, couple of questions”
  1. seanhAug 27, 2009
  2. Sverre RabbelierAug 27, 2009
  3. Matthieu MoyAug 27, 2009
  4. Paolo BonziniAug 28, 2009
  5. Matthieu MoyAug 28, 2009
  6. seanhAug 28, 2009
  7. Matthieu MoyAug 28, 2009
  8. Matthias AndreeAug 28, 2009
  9. Merging in Subversion 1.5 (was: Re: Using git to track my PhD thesis, couple of questions)Jakub Narebski, Aug 28, 2009
  10. Avery PennarunAug 28, 2009
  11. Matthias AndreeAug 28, 2009
  12. Jakub NarebskiAug 28, 2009
  13. Matthias AndreeAug 28, 2009
  14. Avery PennarunAug 28, 2009
  15. Sam VilainAug 30, 2009
  16. Dmitry PotapovAug 31, 2009
  17. david@lang.hmAug 28, 2009
  18. Paolo BonziniAug 28, 2009
  19. demerphqAug 28, 2009
  20. david@lang.hmAug 28, 2009
  21. demerphqAug 28, 2009
  22. Junio C HamanoAug 27, 2009
  23. demerphqAug 27, 2009

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.