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

Revert-style merge/Working tree-only checkout?

From
YRYuriy Romanenko <groman@gmail.com>
Date
Dec 13, 2010, 23:30 UTC
Message-ID
<AANLkTi=ioX25aqXg-yWDA0oXBTATkFe+J25g-dB7-psS@mail.gmail.com>
Hello,

I am somewhat new to Git and I keep running into having to accomplish a certain task and reading through the documentation I can't seem to find any way of doing this easily.

The problem is when branches diverge and I want to sync a branch to another branch with full overwrite, but maintain history and maintain separate branches.

For example, say there is a branch "master" and I create a branch "b1" from master at some point. After this, there are 5 commits (C1,C2,C3,C4,C5) to master and 17 commits to b1 (let's call them cb1, cb2, cb3, ..., cb17). Say I want to create an 18-th commit to "b1" that makes it identical to the C5 (current) state of master. Essentially a single commit wipe of changes cb1 -> cb17 as well as application of C1->C5. So far I have found one way of accomplishing this, but it is difficult, error prone, slow and I just plain don't like it. I feel like there should be an easier way.

What I currently do:

$ rm -rf * $ git checkout -f master $ tar -cvzf /tmp/master.tar.gz * $ git checkout b1 $ rm -rf * $ tar -xvzf /tmp/master.tar.gz $ git add $ git commit -a $ git merge master

I've considered doing something like the following

$ git checkout b1 $ git revert b1~17..b1 $ git merge master

but it also seems wrong, and requires me to count the submits by hand, which seems silly --> I'm not actually reverting anything. I don't know if this would even work.

Any suggestions on how to accomplish this easier? Some sort of a force-checkout that affects working tree only but not the index?

Thank you,
Yuriy
Next: Konstantin Khomoutov
Message 1 of 4 in “Revert-style merge/Working tree-only checkout?”
  1. Yuriy RomanenkoDec 13, 2010
  2. Konstantin KhomoutovDec 14, 2010
  3. Andreas SchwabDec 14, 2010
  4. Neal KreitzingerDec 14, 2010

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.