Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce git-pstash (public stash) #410

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

introduce git-pstash (public stash) #410

wants to merge 1 commit into from

Conversation

ihoro
Copy link
Contributor

@ihoro ihoro commented Jul 29, 2015

No description provided.

}
set_ref()
{
ref=$(echo -n "$1" | tr ' \t' '_')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change echo -n to printf?

@nicolaiskogheim
Copy link
Collaborator

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.

@ihoro
Copy link
Contributor Author

ihoro commented Jul 31, 2015

Good notice, thank you. I agree that pstash will be better if it follows existing stash. Going to revise it.

$ git pstash save
```

Any of the above creates new stash with "${USER}_${current_branch_name}_wip" name. Your working directory is left untouched.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be wip/${USER}/${current_branch_name} to follow branch name convention.

@nicolaiskogheim
Copy link
Collaborator

How are the revising going along, @phigoro? :)

@kiprasmel
Copy link

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 kiprasmel/git-backup#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.

@bl-ue
Copy link

bl-ue commented May 29, 2021

I think we should close this — it's quite out-of-date and old (6 years old).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants