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

RE: Updating Files

From
Ben Walton <bwalton@artsci.utoronto.ca>
Date
Nov 10, 2011, 01:08 UTC
Message-ID
<1320887258-sup-7544@pinkfloyd.chass.utoronto.ca>
In-Reply-To
<338A71EC3E356A47BF5279971E4EF72A04D860D7F6@WESMSG51.nordsoncorp.local>
Excerpts from Brand, Greg's message of Wed Nov 09 19:54:34 -0500 2011:
Hi Greg,
Show 5 quoted lines
>                .<filename>.revision    ~ Does GIT have the same, or
> similar options???  I understand with the distributed nature of GIT,
> there may be several ways to accomplish this. It is nice, though, to
> be able to get a clean version without losing changes you may (or
> may not) want to keep.

You've got at least two options to store changes you want to keep but have them kept out of the way.

1. Commit the change on a branch and leave that branch sitting there.
2. Stash the change with a descriptive note.

If you're on branch master and want to save this change but not have it 'live' you could do:

git checkout -b save_my_change git add modified_file git commit -m 'saving this for later, just in case' git checkout master

The master branch will not have the change but the save_my_change branch will. You can see the commit with a command like:

git show save_my_change

That looks up the sha1 for the ref that save_my_change refers to and then shows the commit object. To re-apply this later, you could merge the branch to master or cherry pick the sha1 to master (or any other branch).

The second option, stashing, is likely nicer for this type of thing but ymmv. In your working tree, with the modified file(s), do:

git stash save -m 'something potentially useful, but maybe not'
Your working tree is now clean and you can see stashes with:
git stash list
You can later get at a stash with git stash apply.

The real gurus may point out something nicer that I didn't think of too...

Hope this helps.

Thanks -Ben -- Ben Walton Systems Programmer - CHASS University of Toronto C:416.407.5610 | W:416.978.4302

Previous: Andrew Ardill
Message 3 of 3 in “RE: Updating Files”
  1. Brand, GregNov 10, 2011
  2. Andrew ArdillNov 10, 2011
  3. Ben WaltonNov 10, 2011

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.