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

OK, how should I have done this...

From
PDPatrick Doyle <wpdster@gmail.com>
Date
Nov 22, 2010, 13:22 UTC
Message-ID
<AANLkTim0_J0i_a0o+z1oCC4mramfUxCGtCg_Y+ab+h+-@mail.gmail.com>

I just checked in modifications to 1/2 dozen or so files in a single commit and pushed them to my server.

Then I switched to a different machine, pulled the latest version of my repository from the server, tried running my code, and discovered that I introduced a problem that didn't manifest itself when running on my laptop.

So now I want to figure out which modification(s) in which file(s) introduced the problem.

I did a git log and saw that things were fine back at commit 5ccce3, so I did
$ git checkout 5ccce3

fully expecting (and seeing) the warning about 'moving to "5ccce3" which isn't a local branch'

ran my code.  It worked (as expected).
$ git diff --name-status master
Saw the list of files that had changed.
$ git checkout master -- file1

Grabbed the version of file1 from master & reran my test. It passed. Repeated the process until I'd identified the set of 3 files that caused things to break, and fixed those three files.

Now I want to check those 3 files in on the master branch. My first inclination, since every time I've tried doing stuff like this in the past has failed miserably, was to copy those 3 files to a safe location, revert them to their unmodified state, switch to the master branch, copy the modified files into my working directory, and commit them.

Instead, I did:
$ git checkout master

hoping that would just switch me to the master branch, keeping those 3 modified files. Instead, what I got was:

error: Entry 'blah/file7' not uptodate.  Cannot merge.

and now "git status" shows a bunch of files staged to be committed (all the files that were different between master and rev 5ccce3) and my 3 files with their modifications.

I'm gonna go back to plan A, copy those 3 files to someplace safe, and checkout/reset until I get back to a clean checkout of master, copy those 3 files in, and commit that change.

But I _know_ that there must be a better way to do this. What should I have done?

--wpd
Next: Matthieu Moy
Message 1 of 7 in “OK, how should I have done this...”
  1. Patrick DoyleNov 22, 2010
  2. Matthieu MoyNov 22, 2010
  3. Patrick DoyleNov 22, 2010
  4. Tay Ray ChuanNov 22, 2010
  5. Matthieu MoyNov 22, 2010
  6. Junio C HamanoNov 23, 2010
  7. Patrick DoyleNov 23, 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.