drewdeponte / git-ps

Patch Stack workflow CLI extension for Git
MIT License
50 stars 4 forks source link

add `git ps co <patch-index>` as convenience mechanism to checkout a particular patch #40

Closed drewdeponte closed 3 years ago

drewdeponte commented 3 years ago

this is in mainline now so I am closing this issue.

brandonpittman commented 2 years ago

@drewdeponte What's the best way to make use of this?

RyanHedges commented 2 years ago

If I remember correctly it's something like...

git-ps ls
  1     8781e4 foo commit
  0     6eb32f bar change

then...

git-ps co 0

to change to that commit. Now HEAD will be on 6eb32f. It replaces something like git checkout 6eb32f

drewdeponte commented 2 years ago

@brandonpittman yeah @RyanHedges is correct in terms of tactically how you accomplish it.

As for the use case I most commonly use this feature for is when I want to validate behavior of code base prior to a patch or series of patches being applied.

So it might go something like the following:

git-ps ls
  2    76b32f car commit
  1     8781e4 foo commit
  0    6eb32f bar change

If I am checked out on main (my patch stack) I am in a state where all 3 patches are applied. However, I need to verify the behavior prior to the foo commit and car commit being applied.

I would simply git-ps co 0, verify the behavior I wanted to verify and then git checkout main to go back to my patch stack.

brandonpittman commented 2 years ago

@drewdeponte @RyanHedges

Thanks! I was wondering about the intended use case.

RyanHedges commented 2 years ago

@drewdeponte Something to think about...

git-ps co 0 goes to "bar change" in your above example. Maybe doing git-ps co or git-ps co h (h for "head") goes back to "car commit". Or maybe a different command entirely like git-ps top. Something like this might be especially helpful if you are one of those that has branches for stacks. It's a way to quickly checkout to the top of the stack you're working in. Only negative I see is it's not that big a deal to git checkout main so its usefulness may appear to be limited.

drewdeponte commented 2 years ago

Yeah that is a nice idea. It would be a nice to have in my mind in terms of priority but I think it is definitely worth it.