git-extras
git-extras copied to clipboard
introduce git-pstash (public stash)
I think this is a good idea.
My thoughts:
Because of the name, I expect it to behave like the regular stash
command. I think this command will gain much more affection if people don't need to learn new stuff.
This is the differences I have noticed so far:
No local changes, empty (p)stash
$ git stash # and git stash save
No local changes to save
$ git pstash # and git pstash save
[pstash] branch: pstash, remote: origin, ref: refs/pstash/nicolai_pstash_wip
remote: warning: Deleting a non-existent ref.
To https://github.com/nicolaiskogheim/git-extras
- [deleted] refs/pstash/nicolai_pstash_wip'
$ git stash [drop | show | apply | pop]
No stash found.
$ git pstash [drop | show | apply | pop]
ERROR: Please, specify stash name. # Or similar
$ git stash clear
(no output)
$ git pstash clear
# option not supported, but silently falls back to doing 'git pstash' (see above)
Local changes, empty (p)stash
$ git stash [save] # Cleans working dir
Saved working directory and index state WIP on pstash: d076097 introduce git-pstash (public stash)
HEAD is now at d076097 introduce git-pstash (public stash)
$ git pstash [save] # Does not touch working dir
[pstash] branch: pstash, remote: origin, ref: refs/pstash/nicolai_pstash_wip
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 513 bytes | 0 bytes/s, done.
Total 5 (delta 4), reused 0 (delta 0)
To https://github.com/nicolaiskogheim/git-extras
* [new branch] 814beb0ff1f981042ce0c807a2ee4d71f802b5fd -> refs/pstash/nicolai_pstash_wip
No local changes, entries in (p)stash
$ git stash [ pop | apply ]
# Applies last stashed changes to work dir. Deletes stash entry if 'pop'.
# Runs git status
# If pop:
Dropped refs/stash@{0} (3e93e59b37acac04aad3acabe4bf32b0f61973a7)
$ git pstash [ pop | apply ] <stash name>
[pstash] branch: pstash, remote: origin, ref: refs/pstash/nicolai_pstash_wip
# If pop
[pstash] branch: pstash, remote: origin, ref: refs/pstash/nicolai_pstash_wip
git d4aead93ad77f81e11d0c1c0122f6007aac52e27 refs/pstash/nicolai_pstash_wip
To https://github.com/nicolaiskogheim/git-extras
Here is me mistyping
git-extras git:(pstash) ✗ git pstash lsit
[pstash] branch: pstash, remote: origin, ref: refs/pstash/nicolai_pstash_wip
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 511 bytes | 0 bytes/s, done.
Total 5 (delta 4), reused 0 (delta 0)
To https://github.com/nicolaiskogheim/git-extras
* [new branch] 64fbdcdbae6f1afbc5b7a7c1c97ab79e40c8b108 -> refs/pstash/nicolai_pstash_wip
Final thoughts: Again, mimicking git stash
would be beneficial. And maybe the user doesn't need to know about details of the branches that gets created.
Good notice, thank you. I agree that pstash will be better if it follows existing stash. Going to revise it.
How are the revising going along, @phigoro? :)
See also https://github.com/sarpik/git-backup -- I see that I've created a very similar feature:D
Mine also supports including untracked changes, but it uses git stash push
instead of git stash create
because create
currently doesn't have such ability
(I've created a FR in git's mailing list)
See https://github.com/sarpik/git-backup/issues/10
Though I haven't made it as clean as this one. I'd be great if we could merge'em up and have a useful command working.
I think we should close this — it's quite out-of-date and old (6 years old).