1

I want to store some files with modifications temporarily and later restore the changes using TortoiseGit. Some thing like the git stash. But I dont see any option to select the files to be stored. Any alternate options like creating patch and restoring can also help.

I need a speedy solution. Preferably using GUI.

MrTux
  • 28,370
  • 24
  • 91
  • 123
Syam Kumar S
  • 792
  • 1
  • 7
  • 24
  • since tortoiseGit is just a GUI for git, and since the functionality you seek _is_ part of Git, if the GUI is ill-designed and doesn't let you to do so, you'll have to use CLI instead. You _are_ trying to use `git stash` – Daemon Painter Nov 18 '20 at 12:57

3 Answers3

3

Since TortoiseGit stash does not allow to select only certain files (as of 2.11):

  • add and commit first what you don't want to stash
  • then stash (with TortoiseGit) the rest

That way, you can go on with only the right files stashed.

MrTux
  • 28,370
  • 24
  • 91
  • 123
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
1

Depending on your scanario you might have different options:

  • If you just want to not commit certain fails as a whole, go to the commit dialog and uncheck those files.

  • As of version 2.11, TortoiseGit does not allow to select certain files for stashing, cf. https://stackoverflow.com/a/64888862/3906760 for a workaround.

  • If you want to partly commit files, you have (at least) two options:

    1. If it this only applies to very few files, then you can use the "Commit and restore" feature of TortoiseGit (cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-commit.html#tgit-dug-commit-restore). Mark a file as "Restore after commit", diff it and make it look as you want to commit it and commit the changes. After the commit the file is restored to the old state.

    2. Commit all files to a new branch, switch back to your "old" branch and then compare the "new" branch to the current working tree and re-apply all changes you want to commit (if that are too many changes, you can also hard reset the "old" branch to the new branch and then perform a mixed reset back to the old commit - then you have all changes in your working tree again). This, can then be done again and again until all changes are committed.

MrTux
  • 28,370
  • 24
  • 91
  • 123
  • another question : isn't there a way to add git scripts to TortoiseGit ? a menu entry, which would execute `git stash -- ${SELECTED_FILES}` ? – LeGEC Nov 18 '20 at 09:44
  • 1
    @LeGEC thanks, there was a word missing. Fixed. ATM, there is no way to add git script to TortoiseGit. – MrTux Nov 18 '20 at 12:15
  • @syam-kumar-s Please consider to uvote/accept this answer if it helped you or leave a comment on what's still missing. – MrTux Dec 18 '20 at 16:38
0

There is the command line way to create the stash :

git stash -- path/file1 path/file2 ...

The created stash is a regular stash entry, you can "stash apply"/"stash pop" through TortoiseGit's GUI afterwards.

LeGEC
  • 29,595
  • 2
  • 37
  • 78
  • I was thinking about [`git stash push`, actually](https://stackoverflow.com/a/42963606/6309). But, considering the OP is about a GUI solution, I didn't mention it. – VonC Nov 18 '20 at 08:26
  • @VonC : isn't there a way to add git scripts to TortoiseGit ? a menu entry, which would execute `git stash -- ${SELECTED_FILES}` ? – LeGEC Nov 18 '20 at 09:35
  • 1
    That might be possible. I am sure MrTux, *the* TortoiseGit specialist, will be able to confirm. – VonC Nov 18 '20 at 09:36
  • ATM, there is no way to add git scripts as TortoiseGit menu entry (cf. https://tortoisegit.org/issue/246). – MrTux Nov 18 '20 at 19:32