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

Re: Merge into locally modified files?

From
AEAndreas Ericsson <exon@op5.com>
Date
Jun 8, 2009, 23:10 UTC
Message-ID
<4A2D9A4A.60804@op5.com>
In-Reply-To
<2729632a0906081030k5048cb27p6950a0decaa7396a@mail.gmail.com>
skillzero@gmail.com wrote:
Show 21 quoted lines
> If I have some local changes to a file that I don't want to commit
> (e.g. temp debug changes like printf's) and I see somebody else has
> pushed some changes to that file, how do I merge their changes to the
> file while trying to preserve my local changes (and conflicting if
> it's not possible)?
> 
> After a git fetch, I tried 'git checkout --merge origin/master <path
> to my locally modified file>', but that just overwrote my local
> changes.
> 
> I'm converting people from CVS to git and this is a common thing
> people do with CVS. They have some local changes and see that the
> server has some other changes so they do 'cvs up' and it tries to
> merge changes from the server into the locally modified file. The
> local changes are often things that will never be committed. I know
> git tries to avoid things you can't undo, but like a 'git checkout
> <file>' that can't be undone, is there a way to say "merge what you
> can and generate conflict markers for things you can't?".
> 
> I think what I want to do is the equivalent of rebasing for local
> modified files rather than committed files.
git stash && git pull && git stash pop
should do roughly what you want.
/Andreas
Previous: Sitaram ChamartyNext: Jon Smirl
Message 6 of 7 in “Merge into locally modified files?”
  1. skillzero@gmail.comJun 8, 2009
  2. Johan HerlandJun 8, 2009
  3. skillzero@gmail.comJun 8, 2009
  4. Johan HerlandJun 8, 2009
  5. Sitaram ChamartyJun 9, 2009
  6. Andreas EricssonJun 8, 2009
  7. Jon SmirlJun 8, 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.