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

[Feature- Request] Option to commit after checking out branch command is made

From
NMNinivaggi Mattia <mattia.ninivaggi@helsana.ch>
Date
Nov 15, 2017, 15:27 UTC
Message-ID
<670f44c0ac554f2faec5a6112376b015@MSSMAILP06.ads.hel.kko.ch>
Hey guys
Sometimes I tend to forget to commit changes before I checkout another branch and the following scenario happens (via cli on windows [with git bash]):
1. I checkout a branch, without having commited first
    > git checkout dev
2. I get this error message:
    > error: Your local changes to the following files would be overwritten by checkout:
    > // List of files
    > // ..
    > //
    > Please commit your changes or stash them before you switch branches.
But I would rather prefer a scenario like this:
1. I checkout a branch, without having commited first
    > git checkout dev
2. I get a message like this:
    > Your local changes to the following files would be overwritten by checkout:
    > // List of files
    > // ..
    > //
    > Would you want to commit first? (y/n))

IF y --> prompt for commit message and commit automatically IF n --> display error message: "Please commit your changes or stash them before you switch branches"

This would be a faster/ more productive way to handle this error.
I think it wont be a big challenge, you just should put a message in the cli-tool when this error occurs and call the commit functionality if "y" is pressed. If you'd like I'll even consider doing it myself. If you have some documentation or some tipps on where to look for it.
Cheers
Ninivaggi Mattia
Next: Junio C Hamano
Message 1 of 4 in “[Feature- Request] Option to commit after checking out branch command is made”
  1. Ninivaggi MattiaNov 15, 2017
  2. Junio C HamanoNov 16, 2017
  3. Ninivaggi MattiaNov 16, 2017
  4. Fwd: [Feature- Request] Option to commit after checking out branch command is madeDavid Eisner, Jun 3, 2019

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.