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

"git checkout" resets modified files

From
SHSteve Heyns <notzippy@gmail.com>
Date
Aug 29, 2015, 06:15 UTC
Message-ID
<CANDob0LdQpoSfsedPK_yhNunXBvNTc9L1zKOM9h8dBUDePs0kg@mail.gmail.com>
"git checkout" resets modified files
Version git  2.5.0,

Description: I was automating a process that would pull and switch to another branch when I stumbled across this. I have not been able to emulate this from command line but using go (or I imagine other languages are similar) if you execute a command like

exec.Command("git","checkout","")
A checkout with the branch parameter but the branch parameter is empty.

The result is git resets the the repository, modified files are reset back to original state without warning.

I would expect the behavior should be the same as a "git checkout" command

Has anyone else seen something like this ? For myself the solution was to simply suppress passing in the revision as a third argument if the revision was empty. But this does appear to be an off behavior.

Thanks Nz

Next: Junio C Hamano
Message 1 of 3 in “"git checkout" resets modified files”
  1. Steve HeynsAug 29, 2015
  2. Junio C HamanoAug 29, 2015
  3. Junio C HamanoAug 29, 2015

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.